xref: /openbmc/linux/fs/xfs/xfs_log.h (revision 1234351cba958cd5d4338172ccfc869a687cd736)
11da177e4SLinus Torvalds /*
27b718769SNathan Scott  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
37b718769SNathan Scott  * All Rights Reserved.
41da177e4SLinus Torvalds  *
57b718769SNathan Scott  * This program is free software; you can redistribute it and/or
67b718769SNathan Scott  * modify it under the terms of the GNU General Public License as
71da177e4SLinus Torvalds  * published by the Free Software Foundation.
81da177e4SLinus Torvalds  *
97b718769SNathan Scott  * This program is distributed in the hope that it would be useful,
107b718769SNathan Scott  * but WITHOUT ANY WARRANTY; without even the implied warranty of
117b718769SNathan Scott  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
127b718769SNathan Scott  * GNU General Public License for more details.
131da177e4SLinus Torvalds  *
147b718769SNathan Scott  * You should have received a copy of the GNU General Public License
157b718769SNathan Scott  * along with this program; if not, write the Free Software Foundation,
167b718769SNathan Scott  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
171da177e4SLinus Torvalds  */
181da177e4SLinus Torvalds #ifndef	__XFS_LOG_H__
191da177e4SLinus Torvalds #define __XFS_LOG_H__
201da177e4SLinus Torvalds 
21fc06c6d0SDave Chinner struct xfs_log_vec {
22fc06c6d0SDave Chinner 	struct xfs_log_vec	*lv_next;	/* next lv in build list */
23fc06c6d0SDave Chinner 	int			lv_niovecs;	/* number of iovecs in lv */
24fc06c6d0SDave Chinner 	struct xfs_log_iovec	*lv_iovecp;	/* iovec array */
25fc06c6d0SDave Chinner 	struct xfs_log_item	*lv_item;	/* owner */
26fc06c6d0SDave Chinner 	char			*lv_buf;	/* formatted buffer */
27fc06c6d0SDave Chinner 	int			lv_buf_len;	/* size of formatted buffer */
287492c5b4SDave Chinner 	int			lv_size;	/* size of allocated lv */
29fc06c6d0SDave Chinner };
301da177e4SLinus Torvalds 
31fc06c6d0SDave Chinner #define XFS_LOG_VEC_ORDERED	(-1)
32fc06c6d0SDave Chinner 
33*1234351cSChristoph Hellwig static inline void *
34*1234351cSChristoph Hellwig xlog_copy_iovec(struct xfs_log_iovec **vecp, uint type, void *data, int len)
35*1234351cSChristoph Hellwig {
36*1234351cSChristoph Hellwig 	struct xfs_log_iovec *vec = *vecp;
37*1234351cSChristoph Hellwig 
38*1234351cSChristoph Hellwig 	vec->i_type = type;
39*1234351cSChristoph Hellwig 	vec->i_addr = data;
40*1234351cSChristoph Hellwig 	vec->i_len = len;
41*1234351cSChristoph Hellwig 
42*1234351cSChristoph Hellwig 	*vecp = vec + 1;
43*1234351cSChristoph Hellwig 	return vec->i_addr;
44*1234351cSChristoph Hellwig }
45*1234351cSChristoph Hellwig 
46fc06c6d0SDave Chinner /*
47fc06c6d0SDave Chinner  * Structure used to pass callback function and the function's argument
48fc06c6d0SDave Chinner  * to the log manager.
49fc06c6d0SDave Chinner  */
50fc06c6d0SDave Chinner typedef struct xfs_log_callback {
51fc06c6d0SDave Chinner 	struct xfs_log_callback	*cb_next;
52fc06c6d0SDave Chinner 	void			(*cb_func)(void *, int);
53fc06c6d0SDave Chinner 	void			*cb_arg;
54fc06c6d0SDave Chinner } xfs_log_callback_t;
55fc06c6d0SDave Chinner 
561da177e4SLinus Torvalds /*
57c41564b5SNathan Scott  * By comparing each component, we don't have to worry about extra
581da177e4SLinus Torvalds  * endian issues in treating two 32 bit numbers as one 64 bit number
591da177e4SLinus Torvalds  */
60a1365647SAndrew Morton static inline xfs_lsn_t	_lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
611da177e4SLinus Torvalds {
621da177e4SLinus Torvalds 	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
631da177e4SLinus Torvalds 		return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds 	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
661da177e4SLinus Torvalds 		return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds 	return 0;
691da177e4SLinus Torvalds }
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds #define	XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
721da177e4SLinus Torvalds 
731da177e4SLinus Torvalds /*
741da177e4SLinus Torvalds  * Macros, structures, prototypes for interface to the log manager.
751da177e4SLinus Torvalds  */
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds /*
781da177e4SLinus Torvalds  * Flags to xfs_log_done()
791da177e4SLinus Torvalds  */
801da177e4SLinus Torvalds #define XFS_LOG_REL_PERM_RESERV	0x1
811da177e4SLinus Torvalds 
821da177e4SLinus Torvalds /*
831da177e4SLinus Torvalds  * Flags to xfs_log_force()
841da177e4SLinus Torvalds  *
851da177e4SLinus Torvalds  *	XFS_LOG_SYNC:	Synchronous force in-core log to disk
861da177e4SLinus Torvalds  */
871da177e4SLinus Torvalds #define XFS_LOG_SYNC		0x1
881da177e4SLinus Torvalds 
891da177e4SLinus Torvalds /* Log manager interfaces */
901da177e4SLinus Torvalds struct xfs_mount;
9135a8a72fSChristoph Hellwig struct xlog_in_core;
92cc09c0dcSDave Chinner struct xlog_ticket;
9343f5efc5SDave Chinner struct xfs_log_item;
9443f5efc5SDave Chinner struct xfs_item_ops;
95955833cfSDave Chinner struct xfs_trans;
96239880efSDave Chinner struct xfs_log_callback;
9735a8a72fSChristoph Hellwig 
981da177e4SLinus Torvalds xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
9935a8a72fSChristoph Hellwig 		       struct xlog_ticket *ticket,
10035a8a72fSChristoph Hellwig 		       struct xlog_in_core **iclog,
1011da177e4SLinus Torvalds 		       uint		flags);
102f538d4daSChristoph Hellwig int	  _xfs_log_force(struct xfs_mount *mp,
103f538d4daSChristoph Hellwig 			 uint		flags,
104f538d4daSChristoph Hellwig 			 int		*log_forced);
105b911ca04SDavid Chinner void	  xfs_log_force(struct xfs_mount	*mp,
106a14a348bSChristoph Hellwig 			uint			flags);
107a14a348bSChristoph Hellwig int	  _xfs_log_force_lsn(struct xfs_mount *mp,
108a14a348bSChristoph Hellwig 			     xfs_lsn_t		lsn,
109a14a348bSChristoph Hellwig 			     uint		flags,
110a14a348bSChristoph Hellwig 			     int		*log_forced);
111a14a348bSChristoph Hellwig void	  xfs_log_force_lsn(struct xfs_mount	*mp,
112b911ca04SDavid Chinner 			    xfs_lsn_t		lsn,
113b911ca04SDavid Chinner 			    uint		flags);
1141da177e4SLinus Torvalds int	  xfs_log_mount(struct xfs_mount	*mp,
1151da177e4SLinus Torvalds 			struct xfs_buftarg	*log_target,
1161da177e4SLinus Torvalds 			xfs_daddr_t		start_block,
1171da177e4SLinus Torvalds 			int		 	num_bblocks);
1184249023aSChristoph Hellwig int	  xfs_log_mount_finish(struct xfs_mount *mp);
11909a423a3SChristoph Hellwig xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
1201c304625SChristoph Hellwig xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp);
121cfb7cdcaSChristoph Hellwig void	  xfs_log_space_wake(struct xfs_mount *mp);
1221da177e4SLinus Torvalds int	  xfs_log_notify(struct xfs_mount	*mp,
12335a8a72fSChristoph Hellwig 			 struct xlog_in_core	*iclog,
124239880efSDave Chinner 			 struct xfs_log_callback *callback_entry);
1251da177e4SLinus Torvalds int	  xfs_log_release_iclog(struct xfs_mount *mp,
12635a8a72fSChristoph Hellwig 			 struct xlog_in_core	 *iclog);
1271da177e4SLinus Torvalds int	  xfs_log_reserve(struct xfs_mount *mp,
1281da177e4SLinus Torvalds 			  int		   length,
1291da177e4SLinus Torvalds 			  int		   count,
13035a8a72fSChristoph Hellwig 			  struct xlog_ticket **ticket,
1311da177e4SLinus Torvalds 			  __uint8_t	   clientid,
1329006fb91SChristoph Hellwig 			  bool		   permanent,
1337e9c6396STim Shimmin 			  uint		   t_type);
1349006fb91SChristoph Hellwig int	  xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic);
1351da177e4SLinus Torvalds int	  xfs_log_unmount_write(struct xfs_mount *mp);
13621b699c8SChristoph Hellwig void      xfs_log_unmount(struct xfs_mount *mp);
1371da177e4SLinus Torvalds int	  xfs_log_force_umount(struct xfs_mount *mp, int logerror);
1381da177e4SLinus Torvalds int	  xfs_log_need_covered(struct xfs_mount *mp);
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds void	  xlog_iodone(struct xfs_buf *);
1411da177e4SLinus Torvalds 
142cc09c0dcSDave Chinner struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket);
143cc09c0dcSDave Chinner void	  xfs_log_ticket_put(struct xlog_ticket *ticket);
144cc09c0dcSDave Chinner 
1450244b960SChristoph Hellwig int	xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp,
14671e330b5SDave Chinner 				xfs_lsn_t *commit_lsn, int flags);
147ccf7c23fSDave Chinner bool	xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
14871e330b5SDave Chinner 
149f661f1e0SDave Chinner void	xfs_log_work_queue(struct xfs_mount *mp);
150f661f1e0SDave Chinner void	xfs_log_worker(struct work_struct *work);
151c75921a7SDave Chinner void	xfs_log_quiesce(struct xfs_mount *mp);
152f661f1e0SDave Chinner 
1531da177e4SLinus Torvalds #endif	/* __XFS_LOG_H__ */
154