| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 2 | * Copyright (c) 2003-2005 Silicon Graphics, Inc.  All Rights Reserved. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #ifndef __XFS_IOMAP_H__ | 
|  | 33 | #define __XFS_IOMAP_H__ | 
|  | 34 |  | 
|  | 35 | #define IOMAP_DADDR_NULL ((xfs_daddr_t) (-1LL)) | 
|  | 36 |  | 
|  | 37 |  | 
|  | 38 | typedef enum {				/* iomap_flags values */ | 
|  | 39 | IOMAP_EOF =		0x01,	/* mapping contains EOF   */ | 
|  | 40 | IOMAP_HOLE =		0x02,	/* mapping covers a hole  */ | 
|  | 41 | IOMAP_DELAY =		0x04,	/* mapping covers delalloc region  */ | 
|  | 42 | IOMAP_REALTIME =	0x10,	/* mapping on the realtime device  */ | 
|  | 43 | IOMAP_UNWRITTEN =	0x20,	/* mapping covers allocated */ | 
|  | 44 | /* but uninitialized file data  */ | 
|  | 45 | IOMAP_NEW =		0x40	/* just allocate */ | 
|  | 46 | } iomap_flags_t; | 
|  | 47 |  | 
|  | 48 | typedef enum { | 
|  | 49 | /* base extent manipulation calls */ | 
|  | 50 | BMAPI_READ = (1 << 0),		/* read extents */ | 
|  | 51 | BMAPI_WRITE = (1 << 1),		/* create extents */ | 
|  | 52 | BMAPI_ALLOCATE = (1 << 2),	/* delayed allocate to real extents */ | 
|  | 53 | BMAPI_UNWRITTEN  = (1 << 3),	/* unwritten extents to real extents */ | 
|  | 54 | /* modifiers */ | 
|  | 55 | BMAPI_IGNSTATE = (1 << 4),	/* ignore unwritten state on read */ | 
| Nathan Scott | 24e17b5 | 2005-05-05 13:33:20 -0700 | [diff] [blame] | 56 | BMAPI_DIRECT = (1 << 5),	/* direct instead of buffered write */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | BMAPI_MMAP = (1 << 6),		/* allocate for mmap write */ | 
|  | 58 | BMAPI_SYNC = (1 << 7),		/* sync write to flush delalloc space */ | 
|  | 59 | BMAPI_TRYLOCK = (1 << 8),	/* non-blocking request */ | 
|  | 60 | BMAPI_DEVICE = (1 << 9),	/* we only want to know the device */ | 
|  | 61 | } bmapi_flags_t; | 
|  | 62 |  | 
|  | 63 |  | 
|  | 64 | /* | 
|  | 65 | * xfs_iomap_t:  File system I/O map | 
|  | 66 | * | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 67 | * The iomap_bn field is expressed in 512-byte blocks, and is where the | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | * mapping starts on disk. | 
|  | 69 | * | 
|  | 70 | * The iomap_offset, iomap_bsize and iomap_delta fields are in bytes. | 
|  | 71 | * iomap_offset is the offset of the mapping in the file itself. | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 72 | * iomap_bsize is the size of the mapping,  iomap_delta is the | 
|  | 73 | * desired data's offset into the mapping, given the offset supplied | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | * to the file I/O map routine. | 
|  | 75 | * | 
|  | 76 | * When a request is made to read beyond the logical end of the object, | 
|  | 77 | * iomap_size may be set to 0, but iomap_offset and iomap_length should be set | 
|  | 78 | * to the actual amount of underlying storage that has been allocated, if any. | 
|  | 79 | */ | 
|  | 80 |  | 
|  | 81 | typedef struct xfs_iomap { | 
|  | 82 | xfs_daddr_t		iomap_bn;	/* first 512b blk of mapping */ | 
|  | 83 | xfs_buftarg_t		*iomap_target; | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 84 | xfs_off_t		iomap_offset;	/* offset of mapping, bytes */ | 
|  | 85 | xfs_off_t		iomap_bsize;	/* size of mapping, bytes */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | size_t			iomap_delta;	/* offset into mapping, bytes */ | 
|  | 87 | iomap_flags_t		iomap_flags; | 
|  | 88 | } xfs_iomap_t; | 
|  | 89 |  | 
|  | 90 | struct xfs_iocore; | 
|  | 91 | struct xfs_inode; | 
|  | 92 | struct xfs_bmbt_irec; | 
|  | 93 |  | 
|  | 94 | extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int, | 
|  | 95 | struct xfs_iomap *, int *); | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 96 | extern int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | int, struct xfs_bmbt_irec *, int *, int); | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 98 | extern int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | struct xfs_bmbt_irec *, int *); | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 100 | extern int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t, size_t, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | struct xfs_bmbt_irec *, int *); | 
| Nathan Scott | f403b7f | 2005-05-05 13:33:40 -0700 | [diff] [blame] | 102 | extern int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, size_t); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 |  | 
|  | 104 | #endif /* __XFS_IOMAP_H__*/ |