⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xfs_log_priv.h

📁 linux 内核源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms 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.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write the Free Software Foundation, * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */#ifndef	__XFS_LOG_PRIV_H__#define __XFS_LOG_PRIV_H__struct xfs_buf;struct ktrace;struct log;struct xlog_ticket;struct xfs_buf_cancel;struct xfs_mount;/* * Macros, structures, prototypes for internal log manager use. */#define XLOG_MIN_ICLOGS		2#define XLOG_MAX_ICLOGS		8#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_MIN_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_MIN_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_ANY_LSN_HOST(lsn,cycle,block)  \    { \	(lsn) = ((xfs_lsn_t)(cycle)<<32)|(block); \    }#define ASSIGN_ANY_LSN_DISK(lsn,cycle,block)  \    { \	INT_SET(((uint *)&(lsn))[0], ARCH_CONVERT, (cycle)); \	INT_SET(((uint *)&(lsn))[1], ARCH_CONVERT, (block)); \    }#define ASSIGN_LSN(lsn,log) \    ASSIGN_ANY_LSN_DISK(lsn,(log)->l_curr_cycle,(log)->l_curr_block);#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. */#ifndef XFS_NATIVE_HOST#define GET_CLIENT_ID(i,arch) \    ((i) & 0xff)#else#define GET_CLIENT_ID(i,arch) \    ((i) >> 24)#endif#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 */#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 * non-dummy transaction. The first dummy changes the h_tail_lsn to * the first transaction before the dummy. The second dummy causes * h_tail_lsn to point to the first dummy. Recovery starts at h_tail_lsn. * * These dummy transactions get committed when everything * is idle (after there has been some activity). * * There are 5 states used to control this. * *  IDLE -- no logging has been done on the file system or *		we are done covering previous transactions. *  NEED -- logging has occurred and we need a dummy transaction *		when the log becomes idle. *  DONE -- we were in the NEED state and have committed a dummy *		transaction. *  NEED2 -- we detected that a dummy transaction has gone to the *		on disk log with no other transactions. *  DONE2 -- we committed a dummy transaction when in the NEED2 state. * * There are two places where we switch states: * * 1.) In xfs_sync, when we detect an idle log and are in NEED or NEED2. *	We commit the dummy transaction and switch to DONE or DONE2, *	respectively. In all other states, we don't do anything. * * 2.) When we finish writing the on-disk log (xlog_state_clean_log). * *	No matter what state we are in, if this isn't the dummy *	transaction going out, the next state is NEED. *	So, if we aren't in the DONE or DONE2 states, the next state *	is NEED. We can't be finishing a write of the dummy record *	unless it was committed and the state switched to DONE or DONE2. * *	If we are in the DONE state and this was a write of the *		dummy transaction, we move to NEED2. * *	If we are in the DONE2 state and this was a write of the *		dummy transaction, we move to IDLE. * * * Writing only one dummy transaction can get appended to * one file space allocation. When this happens, the log recovery * code replays the space allocation and a file could be truncated. * This is why we have the NEED2 and DONE2 states before going idle. */#define XLOG_STATE_COVER_IDLE	0#define XLOG_STATE_COVER_NEED	1#define XLOG_STATE_COVER_DONE	2#define XLOG_STATE_COVER_NEED2	3#define XLOG_STATE_COVER_DONE2	4#define XLOG_COVER_OPS		5

⌨️ 快捷键说明

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