blob: 90233037fab1285c9cef79c127645f7e98b021a5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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#ifndef __XFS_RW_H__
33#define __XFS_RW_H__
34
35struct xfs_buf;
36struct xfs_inode;
37struct xfs_mount;
38
39/*
40 * Maximum count of bmaps used by read and write paths.
41 */
42#define XFS_MAX_RW_NBMAPS 4
43
44/*
45 * Counts of readahead buffers to use based on physical memory size.
46 * None of these should be more than XFS_MAX_RW_NBMAPS.
47 */
48#define XFS_RW_NREADAHEAD_16MB 2
49#define XFS_RW_NREADAHEAD_32MB 3
50#define XFS_RW_NREADAHEAD_K32 4
51#define XFS_RW_NREADAHEAD_K64 4
52
53/*
54 * Maximum size of a buffer that we\'ll map. Making this
55 * too big will degrade performance due to the number of
56 * pages which need to be gathered. Making it too small
57 * will prevent us from doing large I/O\'s to hardware that
58 * needs it.
59 *
60 * This is currently set to 512 KB.
61 */
62#define XFS_MAX_BMAP_LEN_BB 1024
63#define XFS_MAX_BMAP_LEN_BYTES 524288
64
65/*
66 * Convert the given file system block to a disk block.
67 * We have to treat it differently based on whether the
68 * file is a real time file or not, because the bmap code
69 * does.
70 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb)
Nathan Scotta844f452005-11-02 14:38:42 +110072static inline xfs_daddr_t
73xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
74{
75 return (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \
Nathan Scotta844f452005-11-02 14:38:42 +110077 XFS_FSB_TO_DADDR((ip)->i_mount, (fsb)));
78}
79#define XFS_FSB_TO_DB_IO(io,fsb) xfs_fsb_to_db_io(io,fsb)
80static inline xfs_daddr_t
81xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb)
82{
83 return (((io)->io_flags & XFS_IOCORE_RT) ? \
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
Nathan Scotta844f452005-11-02 14:38:42 +110085 XFS_FSB_TO_DADDR((io)->io_mount, (fsb)));
86}
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88/*
89 * Prototypes for functions in xfs_rw.c.
90 */
Nathan Scotta844f452005-11-02 14:38:42 +110091extern int xfs_write_clear_setuid(struct xfs_inode *ip);
92extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp);
93extern int xfs_bioerror(struct xfs_buf *bp);
94extern int xfs_bioerror_relse(struct xfs_buf *bp);
95extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp,
96 xfs_daddr_t blkno, int len, uint flags,
97 struct xfs_buf **bpp);
98extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
99 xfs_buf_t *bp, xfs_daddr_t blkno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101/*
102 * Prototypes for functions in xfs_vnodeops.c.
103 */
Nathan Scotta844f452005-11-02 14:38:42 +1100104extern int xfs_rwlock(bhv_desc_t *bdp, vrwlock_t write_lock);
105extern void xfs_rwunlock(bhv_desc_t *bdp, vrwlock_t write_lock);
106extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf,
107 xfs_off_t offset, cred_t *credp, int flags);
108extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state,
109 cred_t *credp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111#endif /* __XFS_RW_H__ */