xfs_log_priv.h

来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 565 行 · 第 1/2 页

H
565
字号
/* * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Further, this software is distributed without any warranty that it is * free of the rightful claim of any third person regarding infringement * or the like.  Any license provided herein, whether implied or * otherwise, applies only to this software file.  Patent licenses, if * any, provided herein do not apply to combinations of this program with * other software, or any other product whatsoever. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. * * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, * Mountain View, CA  94043, or: * * http://www.sgi.com * * For further information regarding this notice, see: * * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */#ifndef	__XFS_LOG_PRIV_H__#define __XFS_LOG_PRIV_H__struct xfs_buf;struct ktrace;struct log;struct xfs_buf_cancel;struct xfs_mount;/* * Macros, structures, prototypes for internal log manager use. */#define XLOG_MIN_ICLOGS		2#define XLOG_MED_ICLOGS		4#define XLOG_MAX_ICLOGS		8#define XLOG_CALLBACK_SIZE	10#define XLOG_HEADER_MAGIC_NUM	0xFEEDbabe	/* Invalid cycle number */#define XLOG_VERSION_1		1#define XLOG_VERSION_2		2		/* Large IClogs, Log sunit */#define XLOG_VERSION_OKBITS	(XLOG_VERSION_1 | XLOG_VERSION_2)#define XLOG_RECORD_BSIZE	(16*1024)	/* eventually 32k */#define XLOG_BIG_RECORD_BSIZE	(32*1024)	/* 32k buffers */#define XLOG_MAX_RECORD_BSIZE	(256*1024)#define XLOG_HEADER_CYCLE_SIZE	(32*1024)	/* cycle data in header */#define XLOG_RECORD_BSHIFT	14		/* 16384 == 1 << 14 */#define XLOG_BIG_RECORD_BSHIFT	15		/* 32k == 1 << 15 */#define XLOG_MAX_RECORD_BSHIFT	18		/* 256k == 1 << 18 */#define XLOG_BTOLSUNIT(log, b)  (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \                                 (log)->l_mp->m_sb.sb_logsunit)#define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit)#define XLOG_HEADER_SIZE	512#define XLOG_REC_SHIFT(log) \	BTOBB(1 << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \	 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))#define XLOG_TOTAL_REC_SHIFT(log) \	BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \	 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))/* *  set lsns */#define ASSIGN_LSN_CYCLE(lsn,cycle,arch) \    INT_SET(((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)], arch, (cycle));#define ASSIGN_LSN_BLOCK(lsn,block,arch) \    INT_SET(((uint *)&(lsn))[LSN_FIELD_BLOCK(arch)], arch, (block));#define ASSIGN_ANY_LSN(lsn,cycle,block,arch)  \    { \	ASSIGN_LSN_CYCLE(lsn,cycle,arch); \	ASSIGN_LSN_BLOCK(lsn,block,arch); \    }#define ASSIGN_LSN(lsn,log,arch) \    ASSIGN_ANY_LSN(lsn,(log)->l_curr_cycle,(log)->l_curr_block,arch);#define XLOG_SET(f,b)		(((f) & (b)) == (b))#define GET_CYCLE(ptr, arch) \    (INT_GET(*(uint *)(ptr), arch) == XLOG_HEADER_MAGIC_NUM ? \	 INT_GET(*((uint *)(ptr)+1), arch) : \	 INT_GET(*(uint *)(ptr), arch) \    )#define BLK_AVG(blk1, blk2)	((blk1+blk2) >> 1)#ifdef __KERNEL__/* * get client id from packed copy. * * this hack is here because the xlog_pack code copies four bytes * of xlog_op_header containing the fields oh_clientid, oh_flags * and oh_res2 into the packed copy. * * later on this four byte chunk is treated as an int and the * client id is pulled out. * * this has endian issues, of course. */#if __BYTE_ORDER == __LITTLE_ENDIAN#define GET_CLIENT_ID(i,arch) \    ((i) & 0xff)#else#define GET_CLIENT_ID(i,arch) \    ((i) >> 24)#endif#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_SUB_SPACE)void xlog_grant_sub_space(struct log *log, int bytes, int type);#define XLOG_GRANT_SUB_SPACE(log,bytes,type)	\	xlog_grant_sub_space(log,bytes,type)#else#define XLOG_GRANT_SUB_SPACE(log,bytes,type)				\    {									\	if (type == 'w') {						\		(log)->l_grant_write_bytes -= (bytes);			\		if ((log)->l_grant_write_bytes < 0) {			\			(log)->l_grant_write_bytes += (log)->l_logsize;	\			(log)->l_grant_write_cycle--;			\		}							\	} else {							\		(log)->l_grant_reserve_bytes -= (bytes);		\		if ((log)->l_grant_reserve_bytes < 0) {			\			(log)->l_grant_reserve_bytes += (log)->l_logsize;\			(log)->l_grant_reserve_cycle--;			\		}							\	 }								\    }#endif#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_ADD_SPACE)void xlog_grant_add_space(struct log *log, int bytes, int type);#define XLOG_GRANT_ADD_SPACE(log,bytes,type)	\	xlog_grant_add_space(log,bytes,type)#else#define XLOG_GRANT_ADD_SPACE(log,bytes,type)				\    {									\	if (type == 'w') {						\		(log)->l_grant_write_bytes += (bytes);			\		if ((log)->l_grant_write_bytes > (log)->l_logsize) {	\			(log)->l_grant_write_bytes -= (log)->l_logsize;	\			(log)->l_grant_write_cycle++;			\		}							\	} else {							\		(log)->l_grant_reserve_bytes += (bytes);		\		if ((log)->l_grant_reserve_bytes > (log)->l_logsize) {	\			(log)->l_grant_reserve_bytes -= (log)->l_logsize;\			(log)->l_grant_reserve_cycle++;			\		}							\	 }								\    }#endif#define XLOG_INS_TICKETQ(q,tic)				\    {							\	if (q) {					\		(tic)->t_next	    = (q);		\		(tic)->t_prev	    = (q)->t_prev;	\		(q)->t_prev->t_next = (tic);		\		(q)->t_prev	    = (tic);		\	} else {					\		(tic)->t_prev = (tic)->t_next = (tic);	\		(q) = (tic);				\	}						\	(tic)->t_flags |= XLOG_TIC_IN_Q;		\    }#define XLOG_DEL_TICKETQ(q,tic)				\    {							\	if ((tic) == (tic)->t_next) {			\		(q) = NULL;				\	} else {					\		(q) = (tic)->t_next;			\		(tic)->t_next->t_prev = (tic)->t_prev;	\		(tic)->t_prev->t_next = (tic)->t_next;	\	}						\	(tic)->t_next = (tic)->t_prev = NULL;		\	(tic)->t_flags &= ~XLOG_TIC_IN_Q;		\    }#define GRANT_LOCK(log)		mutex_spinlock(&(log)->l_grant_lock)#define GRANT_UNLOCK(log, s)	mutex_spinunlock(&(log)->l_grant_lock, s)#define LOG_LOCK(log)		mutex_spinlock(&(log)->l_icloglock)#define LOG_UNLOCK(log, s)	mutex_spinunlock(&(log)->l_icloglock, s)#define xlog_panic(args...)	cmn_err(CE_PANIC, ## args)#define xlog_exit(args...)	cmn_err(CE_PANIC, ## args)#define xlog_warn(args...)	cmn_err(CE_WARN, ## args)/* * In core log state */#define XLOG_STATE_ACTIVE    0x0001 /* Current IC log being written to */#define XLOG_STATE_WANT_SYNC 0x0002 /* Want to sync this iclog; no more writes */#define XLOG_STATE_SYNCING   0x0004 /* This IC log is syncing */#define XLOG_STATE_DONE_SYNC 0x0008 /* Done syncing to disk */#define XLOG_STATE_DO_CALLBACK \			     0x0010 /* Process callback functions */#define XLOG_STATE_CALLBACK  0x0020 /* Callback functions now */#define XLOG_STATE_DIRTY     0x0040 /* Dirty IC log, not ready for ACTIVE status*/#define XLOG_STATE_IOERROR   0x0080 /* IO error happened in sync'ing log */#define XLOG_STATE_ALL	     0x7FFF /* All possible valid flags */#define XLOG_STATE_NOTUSED   0x8000 /* This IC log not being used */#endif	/* __KERNEL__ *//* * Flags to log operation header * * The first write of a new transaction will be preceded with a start * record, XLOG_START_TRANS.  Once a transaction is committed, a commit * record is written, XLOG_COMMIT_TRANS.  If a single region can not fit into * the remainder of the current active in-core log, it is split up into * multiple regions.  Each partial region will be marked with a * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS. * */#define XLOG_START_TRANS	0x01	/* Start a new transaction */#define XLOG_COMMIT_TRANS	0x02	/* Commit this transaction */#define XLOG_CONTINUE_TRANS	0x04	/* Cont this trans into new region */#define XLOG_WAS_CONT_TRANS	0x08	/* Cont this trans into new region */#define XLOG_END_TRANS		0x10	/* End a continued transaction */#define XLOG_UNMOUNT_TRANS	0x20	/* Unmount a filesystem transaction */#define XLOG_SKIP_TRANS		(XLOG_COMMIT_TRANS | XLOG_CONTINUE_TRANS | \				 XLOG_WAS_CONT_TRANS | XLOG_END_TRANS | \				 XLOG_UNMOUNT_TRANS)#ifdef __KERNEL__/* * Flags to log ticket */#define XLOG_TIC_INITED		0x1	/* has been initialized */#define XLOG_TIC_PERM_RESERV	0x2	/* permanent reservation */#define XLOG_TIC_IN_Q		0x4#endif	/* __KERNEL__ */#define XLOG_UNMOUNT_TYPE	0x556e	/* Un for Unmount *//* * Flags for log structure */#define XLOG_CHKSUM_MISMATCH	0x1	/* used only during recovery */#define XLOG_ACTIVE_RECOVERY	0x2	/* in the middle of recovery */#define	XLOG_RECOVERY_NEEDED	0x4	/* log was recovered */#define XLOG_IO_ERROR		0x8	/* log hit an I/O error, and being					   shutdown */typedef __uint32_t xlog_tid_t;#ifdef __KERNEL__/* * Below are states for covering allocation transactions. * By covering, we mean changing the h_tail_lsn in the last on-disk * log write such that no allocation transactions will be re-done during * recovery after a system crash. Recovery starts at the last on-disk * log write. * * These states are used to insert dummy log entries to cover * space allocation transactions which can undo non-transactional changes * after a crash. Writes to a file with space * already allocated do not result in any transactions. Allocations * might include space beyond the EOF. So if we just push the EOF a * little, the last transaction for the file could contain the wrong * size. If there is no file system activity, after an allocation * transaction, and the system crashes, the allocation transaction * will get replayed and the file will be truncated. This could * be hours/days/... after the allocation occurred. * * The fix for this is to do two dummy transactions when the * system is idle. We need two dummy transaction because the h_tail_lsn * in the log record header needs to point beyond the last possible

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?