blob: fcf28dbded7cdbaed63e1d28542b09d697e6d129 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott1e69dd02006-06-19 08:39:53 +10002 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
Nathan Scott7b718762005-11-02 14:58:39 +11003 * 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 */
18#ifndef __XFS_RW_H__
19#define __XFS_RW_H__
20
21struct xfs_buf;
22struct xfs_inode;
23struct xfs_mount;
24
25/*
26 * Maximum count of bmaps used by read and write paths.
27 */
28#define XFS_MAX_RW_NBMAPS 4
29
30/*
31 * Counts of readahead buffers to use based on physical memory size.
32 * None of these should be more than XFS_MAX_RW_NBMAPS.
33 */
34#define XFS_RW_NREADAHEAD_16MB 2
35#define XFS_RW_NREADAHEAD_32MB 3
36#define XFS_RW_NREADAHEAD_K32 4
37#define XFS_RW_NREADAHEAD_K64 4
38
39/*
40 * Maximum size of a buffer that we\'ll map. Making this
41 * too big will degrade performance due to the number of
42 * pages which need to be gathered. Making it too small
43 * will prevent us from doing large I/O\'s to hardware that
44 * needs it.
45 *
46 * This is currently set to 512 KB.
47 */
48#define XFS_MAX_BMAP_LEN_BB 1024
49#define XFS_MAX_BMAP_LEN_BYTES 524288
50
51/*
52 * Convert the given file system block to a disk block.
53 * We have to treat it differently based on whether the
54 * file is a real time file or not, because the bmap code
55 * does.
56 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb)
Nathan Scotta844f452005-11-02 14:38:42 +110058static inline xfs_daddr_t
59xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
60{
61 return (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \
Nathan Scotta844f452005-11-02 14:38:42 +110063 XFS_FSB_TO_DADDR((ip)->i_mount, (fsb)));
64}
65#define XFS_FSB_TO_DB_IO(io,fsb) xfs_fsb_to_db_io(io,fsb)
66static inline xfs_daddr_t
67xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb)
68{
69 return (((io)->io_flags & XFS_IOCORE_RT) ? \
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
Nathan Scotta844f452005-11-02 14:38:42 +110071 XFS_FSB_TO_DADDR((io)->io_mount, (fsb)));
72}
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/*
David Chinner92dfe8d2007-05-24 15:22:19 +100075 * Flags for xfs_free_eofblocks
76 */
77#define XFS_FREE_EOF_LOCK (1<<0)
78#define XFS_FREE_EOF_NOLOCK (1<<1)
79
David Chinner957d0eb2007-06-18 16:50:37 +100080
81/*
82 * helper function to extract extent size hint from inode
83 */
84STATIC_INLINE xfs_extlen_t
85xfs_get_extsz_hint(
86 xfs_inode_t *ip)
87{
88 xfs_extlen_t extsz;
89
90 if (unlikely(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
91 extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
92 ? ip->i_d.di_extsize
93 : ip->i_mount->m_sb.sb_rextsize;
94 ASSERT(extsz);
95 } else {
96 extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
97 ? ip->i_d.di_extsize : 0;
98 }
99 return extsz;
100}
101
David Chinner92dfe8d2007-05-24 15:22:19 +1000102/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 * Prototypes for functions in xfs_rw.c.
104 */
Nathan Scotta844f452005-11-02 14:38:42 +1100105extern int xfs_write_clear_setuid(struct xfs_inode *ip);
Nathan Scott1e69dd02006-06-19 08:39:53 +1000106extern int xfs_write_sync_logforce(struct xfs_mount *mp, struct xfs_inode *ip);
Nathan Scotta844f452005-11-02 14:38:42 +1100107extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp);
108extern int xfs_bioerror(struct xfs_buf *bp);
109extern int xfs_bioerror_relse(struct xfs_buf *bp);
110extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp,
111 xfs_daddr_t blkno, int len, uint flags,
112 struct xfs_buf **bpp);
113extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
114 xfs_buf_t *bp, xfs_daddr_t blkno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116/*
117 * Prototypes for functions in xfs_vnodeops.c.
118 */
Nathan Scott8285fb52006-06-09 17:07:12 +1000119extern int xfs_rwlock(bhv_desc_t *bdp, bhv_vrwlock_t write_lock);
120extern void xfs_rwunlock(bhv_desc_t *bdp, bhv_vrwlock_t write_lock);
121extern int xfs_setattr(bhv_desc_t *, bhv_vattr_t *vap, int flags,
David Chinner92dfe8d2007-05-24 15:22:19 +1000122 cred_t *credp);
Nathan Scotta844f452005-11-02 14:38:42 +1100123extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf,
David Chinner92dfe8d2007-05-24 15:22:19 +1000124 xfs_off_t offset, cred_t *credp, int flags);
Nathan Scotta844f452005-11-02 14:38:42 +1100125extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state,
David Chinner92dfe8d2007-05-24 15:22:19 +1000126 cred_t *credp);
127extern int xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip,
128 int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
130#endif /* __XFS_RW_H__ */