| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 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_LOG_H__ | 
 | 33 | #define __XFS_LOG_H__ | 
 | 34 |  | 
 | 35 | /* get lsn fields */ | 
 | 36 |  | 
 | 37 | #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) | 
 | 38 | #define BLOCK_LSN(lsn) ((uint)(lsn)) | 
 | 39 | /* this is used in a spot where we might otherwise double-endian-flip */ | 
 | 40 | #define CYCLE_LSN_DISK(lsn) (((uint *)&(lsn))[0]) | 
 | 41 |  | 
 | 42 | #ifdef __KERNEL__ | 
 | 43 | /* | 
 | 44 |  * By comparing each compnent, we don't have to worry about extra | 
 | 45 |  * endian issues in treating two 32 bit numbers as one 64 bit number | 
 | 46 |  */ | 
 | 47 | static | 
 | 48 | #if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96)) | 
 | 49 | __attribute__((unused))	/* gcc 2.95, 2.96 miscompile this when inlined */ | 
 | 50 | #else | 
 | 51 | __inline__ | 
 | 52 | #endif | 
 | 53 | xfs_lsn_t	_lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) | 
 | 54 | { | 
 | 55 | 	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) | 
 | 56 | 		return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999; | 
 | 57 |  | 
 | 58 | 	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2)) | 
 | 59 | 		return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999; | 
 | 60 |  | 
 | 61 | 	return 0; | 
 | 62 | } | 
 | 63 |  | 
 | 64 | #define	XFS_LSN_CMP(x,y) _lsn_cmp(x,y) | 
 | 65 |  | 
 | 66 | /* | 
 | 67 |  * Macros, structures, prototypes for interface to the log manager. | 
 | 68 |  */ | 
 | 69 |  | 
 | 70 | /* | 
 | 71 |  * Flags to xfs_log_mount | 
 | 72 |  */ | 
 | 73 | #define XFS_LOG_RECOVER		0x1 | 
 | 74 |  | 
 | 75 | /* | 
 | 76 |  * Flags to xfs_log_done() | 
 | 77 |  */ | 
 | 78 | #define XFS_LOG_REL_PERM_RESERV	0x1 | 
 | 79 |  | 
 | 80 |  | 
 | 81 | /* | 
 | 82 |  * Flags to xfs_log_reserve() | 
 | 83 |  * | 
 | 84 |  *	XFS_LOG_SLEEP:	 If space is not available, sleep (default) | 
 | 85 |  *	XFS_LOG_NOSLEEP: If space is not available, return error | 
 | 86 |  *	XFS_LOG_PERM_RESERV: Permanent reservation.  When writes are | 
 | 87 |  *		performed against this type of reservation, the reservation | 
 | 88 |  *		is not decreased.  Long running transactions should use this. | 
 | 89 |  */ | 
 | 90 | #define XFS_LOG_SLEEP		0x0 | 
 | 91 | #define XFS_LOG_NOSLEEP		0x1 | 
 | 92 | #define XFS_LOG_PERM_RESERV	0x2 | 
 | 93 | #define XFS_LOG_RESV_ALL	(XFS_LOG_NOSLEEP|XFS_LOG_PERM_RESERV) | 
 | 94 |  | 
 | 95 |  | 
 | 96 | /* | 
 | 97 |  * Flags to xfs_log_force() | 
 | 98 |  * | 
 | 99 |  *	XFS_LOG_SYNC:	Synchronous force in-core log to disk | 
 | 100 |  *	XFS_LOG_FORCE:	Start in-core log write now. | 
 | 101 |  *	XFS_LOG_URGE:	Start write within some window of time. | 
 | 102 |  * | 
 | 103 |  * Note: Either XFS_LOG_FORCE or XFS_LOG_URGE must be set. | 
 | 104 |  */ | 
 | 105 | #define XFS_LOG_SYNC		0x1 | 
 | 106 | #define XFS_LOG_FORCE		0x2 | 
 | 107 | #define XFS_LOG_URGE		0x4 | 
 | 108 |  | 
 | 109 | #endif	/* __KERNEL__ */ | 
 | 110 |  | 
 | 111 |  | 
 | 112 | /* Log Clients */ | 
 | 113 | #define XFS_TRANSACTION		0x69 | 
 | 114 | #define XFS_VOLUME		0x2 | 
 | 115 | #define XFS_LOG			0xaa | 
 | 116 |  | 
 | 117 | typedef struct xfs_log_iovec { | 
 | 118 | 	xfs_caddr_t		i_addr;		/* beginning address of region */ | 
 | 119 | 	int		i_len;		/* length in bytes of region */ | 
 | 120 | } xfs_log_iovec_t; | 
 | 121 |  | 
 | 122 | typedef void* xfs_log_ticket_t; | 
 | 123 |  | 
 | 124 | /* | 
 | 125 |  * Structure used to pass callback function and the function's argument | 
 | 126 |  * to the log manager. | 
 | 127 |  */ | 
 | 128 | typedef struct xfs_log_callback { | 
 | 129 | 	struct xfs_log_callback	*cb_next; | 
 | 130 | 	void			(*cb_func)(void *, int); | 
 | 131 | 	void			*cb_arg; | 
 | 132 | } xfs_log_callback_t; | 
 | 133 |  | 
 | 134 |  | 
 | 135 | #ifdef __KERNEL__ | 
 | 136 | /* Log manager interfaces */ | 
 | 137 | struct xfs_mount; | 
 | 138 | xfs_lsn_t xfs_log_done(struct xfs_mount *mp, | 
 | 139 | 		       xfs_log_ticket_t ticket, | 
 | 140 | 		       void		**iclog, | 
 | 141 | 		       uint		flags); | 
 | 142 | int	  xfs_log_force(struct xfs_mount *mp, | 
 | 143 | 			xfs_lsn_t	 lsn, | 
 | 144 | 			uint		 flags); | 
 | 145 | int	  xfs_log_mount(struct xfs_mount	*mp, | 
 | 146 | 			struct xfs_buftarg	*log_target, | 
 | 147 | 			xfs_daddr_t		start_block, | 
 | 148 | 			int		 	num_bblocks); | 
 | 149 | int	  xfs_log_mount_finish(struct xfs_mount *mp, int); | 
 | 150 | void	  xfs_log_move_tail(struct xfs_mount	*mp, | 
 | 151 | 			    xfs_lsn_t		tail_lsn); | 
 | 152 | int	  xfs_log_notify(struct xfs_mount	*mp, | 
 | 153 | 			 void			*iclog, | 
 | 154 | 			 xfs_log_callback_t	*callback_entry); | 
 | 155 | int	  xfs_log_release_iclog(struct xfs_mount *mp, | 
 | 156 | 			 void			 *iclog_hndl); | 
 | 157 | int	  xfs_log_reserve(struct xfs_mount *mp, | 
 | 158 | 			  int		   length, | 
 | 159 | 			  int		   count, | 
 | 160 | 			  xfs_log_ticket_t *ticket, | 
 | 161 | 			  __uint8_t	   clientid, | 
 | 162 | 			  uint		   flags); | 
 | 163 | int	  xfs_log_write(struct xfs_mount *mp, | 
 | 164 | 			xfs_log_iovec_t  region[], | 
 | 165 | 			int		 nentries, | 
 | 166 | 			xfs_log_ticket_t ticket, | 
 | 167 | 			xfs_lsn_t	 *start_lsn); | 
 | 168 | int	  xfs_log_unmount(struct xfs_mount *mp); | 
 | 169 | int	  xfs_log_unmount_write(struct xfs_mount *mp); | 
 | 170 | void      xfs_log_unmount_dealloc(struct xfs_mount *mp); | 
 | 171 | int	  xfs_log_force_umount(struct xfs_mount *mp, int logerror); | 
 | 172 | int	  xfs_log_need_covered(struct xfs_mount *mp); | 
 | 173 |  | 
 | 174 | void	  xlog_iodone(struct xfs_buf *); | 
 | 175 |  | 
 | 176 | #endif | 
 | 177 |  | 
 | 178 |  | 
 | 179 | extern int xlog_debug;		/* set to 1 to enable real log */ | 
 | 180 |  | 
 | 181 |  | 
 | 182 | #endif	/* __XFS_LOG_H__ */ |