xref: /openbmc/linux/fs/xfs/xfs_log.h (revision fc06c6d064dd50f7aa157065ef79216190d75c91)
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 
21*fc06c6d0SDave Chinner #include "xfs_log_format.h"
22b53e675dSChristoph Hellwig 
23*fc06c6d0SDave Chinner struct xfs_log_vec {
24*fc06c6d0SDave Chinner 	struct xfs_log_vec	*lv_next;	/* next lv in build list */
25*fc06c6d0SDave Chinner 	int			lv_niovecs;	/* number of iovecs in lv */
26*fc06c6d0SDave Chinner 	struct xfs_log_iovec	*lv_iovecp;	/* iovec array */
27*fc06c6d0SDave Chinner 	struct xfs_log_item	*lv_item;	/* owner */
28*fc06c6d0SDave Chinner 	char			*lv_buf;	/* formatted buffer */
29*fc06c6d0SDave Chinner 	int			lv_buf_len;	/* size of formatted buffer */
30*fc06c6d0SDave Chinner };
311da177e4SLinus Torvalds 
32*fc06c6d0SDave Chinner #define XFS_LOG_VEC_ORDERED	(-1)
33*fc06c6d0SDave Chinner 
34*fc06c6d0SDave Chinner /*
35*fc06c6d0SDave Chinner  * Structure used to pass callback function and the function's argument
36*fc06c6d0SDave Chinner  * to the log manager.
37*fc06c6d0SDave Chinner  */
38*fc06c6d0SDave Chinner typedef struct xfs_log_callback {
39*fc06c6d0SDave Chinner 	struct xfs_log_callback	*cb_next;
40*fc06c6d0SDave Chinner 	void			(*cb_func)(void *, int);
41*fc06c6d0SDave Chinner 	void			*cb_arg;
42*fc06c6d0SDave Chinner } xfs_log_callback_t;
43*fc06c6d0SDave Chinner 
441da177e4SLinus Torvalds /*
45c41564b5SNathan Scott  * By comparing each component, we don't have to worry about extra
461da177e4SLinus Torvalds  * endian issues in treating two 32 bit numbers as one 64 bit number
471da177e4SLinus Torvalds  */
48a1365647SAndrew Morton static inline xfs_lsn_t	_lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
491da177e4SLinus Torvalds {
501da177e4SLinus Torvalds 	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
511da177e4SLinus Torvalds 		return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds 	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
541da177e4SLinus Torvalds 		return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds 	return 0;
571da177e4SLinus Torvalds }
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #define	XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds /*
621da177e4SLinus Torvalds  * Macros, structures, prototypes for interface to the log manager.
631da177e4SLinus Torvalds  */
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds /*
661da177e4SLinus Torvalds  * Flags to xfs_log_done()
671da177e4SLinus Torvalds  */
681da177e4SLinus Torvalds #define XFS_LOG_REL_PERM_RESERV	0x1
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds /*
711da177e4SLinus Torvalds  * Flags to xfs_log_force()
721da177e4SLinus Torvalds  *
731da177e4SLinus Torvalds  *	XFS_LOG_SYNC:	Synchronous force in-core log to disk
741da177e4SLinus Torvalds  */
751da177e4SLinus Torvalds #define XFS_LOG_SYNC		0x1
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds /* Log manager interfaces */
781da177e4SLinus Torvalds struct xfs_mount;
7935a8a72fSChristoph Hellwig struct xlog_in_core;
80cc09c0dcSDave Chinner struct xlog_ticket;
8143f5efc5SDave Chinner struct xfs_log_item;
8243f5efc5SDave Chinner struct xfs_item_ops;
83955833cfSDave Chinner struct xfs_trans;
8443f5efc5SDave Chinner 
8543f5efc5SDave Chinner void	xfs_log_item_init(struct xfs_mount	*mp,
8643f5efc5SDave Chinner 			struct xfs_log_item	*item,
8743f5efc5SDave Chinner 			int			type,
88272e42b2SChristoph Hellwig 			const struct xfs_item_ops *ops);
8935a8a72fSChristoph Hellwig 
901da177e4SLinus Torvalds xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
9135a8a72fSChristoph Hellwig 		       struct xlog_ticket *ticket,
9235a8a72fSChristoph Hellwig 		       struct xlog_in_core **iclog,
931da177e4SLinus Torvalds 		       uint		flags);
94f538d4daSChristoph Hellwig int	  _xfs_log_force(struct xfs_mount *mp,
95f538d4daSChristoph Hellwig 			 uint		flags,
96f538d4daSChristoph Hellwig 			 int		*log_forced);
97b911ca04SDavid Chinner void	  xfs_log_force(struct xfs_mount	*mp,
98a14a348bSChristoph Hellwig 			uint			flags);
99a14a348bSChristoph Hellwig int	  _xfs_log_force_lsn(struct xfs_mount *mp,
100a14a348bSChristoph Hellwig 			     xfs_lsn_t		lsn,
101a14a348bSChristoph Hellwig 			     uint		flags,
102a14a348bSChristoph Hellwig 			     int		*log_forced);
103a14a348bSChristoph Hellwig void	  xfs_log_force_lsn(struct xfs_mount	*mp,
104b911ca04SDavid Chinner 			    xfs_lsn_t		lsn,
105b911ca04SDavid Chinner 			    uint		flags);
1061da177e4SLinus Torvalds int	  xfs_log_mount(struct xfs_mount	*mp,
1071da177e4SLinus Torvalds 			struct xfs_buftarg	*log_target,
1081da177e4SLinus Torvalds 			xfs_daddr_t		start_block,
1091da177e4SLinus Torvalds 			int		 	num_bblocks);
1104249023aSChristoph Hellwig int	  xfs_log_mount_finish(struct xfs_mount *mp);
11109a423a3SChristoph Hellwig xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
1121c304625SChristoph Hellwig xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp);
113cfb7cdcaSChristoph Hellwig void	  xfs_log_space_wake(struct xfs_mount *mp);
1141da177e4SLinus Torvalds int	  xfs_log_notify(struct xfs_mount	*mp,
11535a8a72fSChristoph Hellwig 			 struct xlog_in_core	*iclog,
1161da177e4SLinus Torvalds 			 xfs_log_callback_t	*callback_entry);
1171da177e4SLinus Torvalds int	  xfs_log_release_iclog(struct xfs_mount *mp,
11835a8a72fSChristoph Hellwig 			 struct xlog_in_core	 *iclog);
1191da177e4SLinus Torvalds int	  xfs_log_reserve(struct xfs_mount *mp,
1201da177e4SLinus Torvalds 			  int		   length,
1211da177e4SLinus Torvalds 			  int		   count,
12235a8a72fSChristoph Hellwig 			  struct xlog_ticket **ticket,
1231da177e4SLinus Torvalds 			  __uint8_t	   clientid,
1249006fb91SChristoph Hellwig 			  bool		   permanent,
1257e9c6396STim Shimmin 			  uint		   t_type);
1269006fb91SChristoph Hellwig int	  xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic);
1271da177e4SLinus Torvalds int	  xfs_log_unmount_write(struct xfs_mount *mp);
12821b699c8SChristoph Hellwig void      xfs_log_unmount(struct xfs_mount *mp);
1291da177e4SLinus Torvalds int	  xfs_log_force_umount(struct xfs_mount *mp, int logerror);
1301da177e4SLinus Torvalds int	  xfs_log_need_covered(struct xfs_mount *mp);
1311da177e4SLinus Torvalds 
1321da177e4SLinus Torvalds void	  xlog_iodone(struct xfs_buf *);
1331da177e4SLinus Torvalds 
134cc09c0dcSDave Chinner struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket);
135cc09c0dcSDave Chinner void	  xfs_log_ticket_put(struct xlog_ticket *ticket);
136cc09c0dcSDave Chinner 
1370244b960SChristoph Hellwig int	xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp,
13871e330b5SDave Chinner 				xfs_lsn_t *commit_lsn, int flags);
139ccf7c23fSDave Chinner bool	xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
14071e330b5SDave Chinner 
141f661f1e0SDave Chinner void	xfs_log_work_queue(struct xfs_mount *mp);
142f661f1e0SDave Chinner void	xfs_log_worker(struct work_struct *work);
143c75921a7SDave Chinner void	xfs_log_quiesce(struct xfs_mount *mp);
144f661f1e0SDave Chinner 
1451da177e4SLinus Torvalds #endif	/* __XFS_LOG_H__ */
146