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

📄 jbd.h

📁 linux得一些常用命令,以及linux环境下的c编程
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * linux/include/linux/jbd.h *  * Written by Stephen C. Tweedie <sct@redhat.com> * * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved * * This file is part of the Linux kernel and is made available under * the terms of the GNU General Public License, version 2, or at your * option, any later version, incorporated herein by reference. * * Definitions for transaction data structures for the buffer cache * filesystem journaling support. */#ifndef _LINUX_JBD_H#define _LINUX_JBD_H#if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || !defined(__KERNEL__)/* Allow this file to be included directly into e2fsprogs */#ifndef __KERNEL__#include "jfs_compat.h"#define JFS_DEBUG#define jfs_debug jbd_debug#else#include <linux/journal-head.h>#include <linux/stddef.h>#include <asm/semaphore.h>#endif#define journal_oom_retry 1/* * Define JBD_PARANOID_WRITES to cause a kernel BUG() check if ext3 * finds a buffer unexpectedly dirty.  This is useful for debugging, but * can cause spurious kernel panics if there are applications such as * tune2fs modifying our buffer_heads behind our backs. */#undef JBD_PARANOID_WRITES#ifdef CONFIG_JBD_DEBUG/* * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal * consistency checks.  By default we don't do this unless * CONFIG_JBD_DEBUG is on. */#define JBD_EXPENSIVE_CHECKINGextern int journal_enable_debug;#define jbd_debug(n, f, a...)						\	do {								\		if ((n) <= journal_enable_debug) {			\			printk (KERN_DEBUG "(%s, %d): %s: ",		\				__FILE__, __LINE__, __FUNCTION__);	\		  	printk (f, ## a);				\		}							\	} while (0)#else#define jbd_debug(f, a...)	/**/#endifextern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry);#define jbd_kmalloc(size, flags) \	__jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)#define jbd_rep_kmalloc(size, flags) \	__jbd_kmalloc(__FUNCTION__, (size), (flags), 1)#define JFS_MIN_JOURNAL_BLOCKS 1024#ifdef __KERNEL__typedef struct handle_s		handle_t;	/* Atomic operation type */typedef struct journal_s	journal_t;	/* Journal control structure */#endif/* * Internal structures used by the logging mechanism: */#define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! *//* * On-disk structures *//*  * Descriptor block types: */#define JFS_DESCRIPTOR_BLOCK	1#define JFS_COMMIT_BLOCK	2#define JFS_SUPERBLOCK_V1	3#define JFS_SUPERBLOCK_V2	4#define JFS_REVOKE_BLOCK	5/* * Standard header for all descriptor blocks: */typedef struct journal_header_s{	__u32		h_magic;	__u32		h_blocktype;	__u32		h_sequence;} journal_header_t;/*  * The block tag: used to describe a single buffer in the journal  */typedef struct journal_block_tag_s{	__u32		t_blocknr;	/* The on-disk block number */	__u32		t_flags;	/* See below */} journal_block_tag_t;/*  * The revoke descriptor: used on disk to describe a series of blocks to * be revoked from the log  */typedef struct journal_revoke_header_s{	journal_header_t r_header;	int		 r_count;	/* Count of bytes used in the block */} journal_revoke_header_t;/* Definitions for the journal tag flags word: */#define JFS_FLAG_ESCAPE		1	/* on-disk block is escaped */#define JFS_FLAG_SAME_UUID	2	/* block has same uuid as previous */#define JFS_FLAG_DELETED	4	/* block deleted by this transaction */#define JFS_FLAG_LAST_TAG	8	/* last tag in this descriptor block *//* * The journal superblock.  All fields are in big-endian byte order. */typedef struct journal_superblock_s{/* 0x0000 */	journal_header_t s_header;/* 0x000C */	/* Static information describing the journal */	__u32	s_blocksize;		/* journal device blocksize */	__u32	s_maxlen;		/* total blocks in journal file */	__u32	s_first;		/* first block of log information */	/* 0x0018 */	/* Dynamic information describing the current state of the log */	__u32	s_sequence;		/* first commit ID expected in log */	__u32	s_start;		/* blocknr of start of log *//* 0x0020 */	/* Error value, as set by journal_abort(). */	__s32	s_errno;/* 0x0024 */	/* Remaining fields are only valid in a version-2 superblock */	__u32	s_feature_compat; 	/* compatible feature set */	__u32	s_feature_incompat; 	/* incompatible feature set */	__u32	s_feature_ro_compat; 	/* readonly-compatible feature set *//* 0x0030 */	__u8	s_uuid[16];		/* 128-bit uuid for journal *//* 0x0040 */	__u32	s_nr_users;		/* Nr of filesystems sharing log */		__u32	s_dynsuper;		/* Blocknr of dynamic superblock copy*/	/* 0x0048 */	__u32	s_max_transaction;	/* Limit of journal blocks per trans.*/	__u32	s_max_trans_data;	/* Limit of data blocks per trans. *//* 0x0050 */	__u32	s_padding[44];/* 0x0100 */	__u8	s_users[16*48];		/* ids of all fs'es sharing the log *//* 0x0400 */} journal_superblock_t;#define JFS_HAS_COMPAT_FEATURE(j,mask)					\	((j)->j_format_version >= 2 &&					\	 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))#define JFS_HAS_RO_COMPAT_FEATURE(j,mask)				\	((j)->j_format_version >= 2 &&					\	 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))#define JFS_HAS_INCOMPAT_FEATURE(j,mask)				\	((j)->j_format_version >= 2 &&					\	 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))#define JFS_FEATURE_INCOMPAT_REVOKE	0x00000001/* Features known to this kernel version: */#define JFS_KNOWN_COMPAT_FEATURES	0#define JFS_KNOWN_ROCOMPAT_FEATURES	0#define JFS_KNOWN_INCOMPAT_FEATURES	JFS_FEATURE_INCOMPAT_REVOKE#ifdef __KERNEL__#include <linux/fs.h>#include <linux/sched.h>#define JBD_ASSERTIONS#ifdef JBD_ASSERTIONS#define J_ASSERT(assert)						\do {									\	if (!(assert)) {						\		printk (KERN_EMERG					\			"Assertion failure in %s() at %s:%d: \"%s\"\n",	\			__FUNCTION__, __FILE__, __LINE__, # assert);	\		BUG();							\	}								\} while (0)#if defined(CONFIG_BUFFER_DEBUG)void buffer_assertion_failure(struct buffer_head *bh);#define J_ASSERT_BH(bh, expr)						\	do {								\		if (!(expr))						\			buffer_assertion_failure(bh);			\		J_ASSERT(expr);						\	} while (0)#define J_ASSERT_JH(jh, expr)	J_ASSERT_BH(jh2bh(jh), expr)#else#define J_ASSERT_BH(bh, expr)	J_ASSERT(expr)#define J_ASSERT_JH(jh, expr)	J_ASSERT(expr)#endif#else#define J_ASSERT(assert)	do { } while (0)#endif		/* JBD_ASSERTIONS */enum jbd_state_bits {	BH_JWrite	  = BH_PrivateStart,	/* 1 if being written to log (@@@ DEBUGGING) */	BH_Freed,		/* 1 if buffer has been freed (truncated) */	BH_Revoked,		/* 1 if buffer has been revoked from the log */	BH_RevokeValid,		/* 1 if buffer revoked flag is valid */	BH_JBDDirty,		/* 1 if buffer is dirty but journaled */};/* Return true if the buffer is one which JBD is managing */static inline int buffer_jbd(struct buffer_head *bh){	return __buffer_state(bh, JBD);}static inline struct buffer_head *jh2bh(struct journal_head *jh){	return jh->b_bh;}static inline struct journal_head *bh2jh(struct buffer_head *bh){	return bh->b_private;}#define HAVE_JOURNAL_CALLBACK_STATUSstruct journal_callback {	struct list_head jcb_list;	void (*jcb_func)(struct journal_callback *jcb, int error);	/* user data goes here */};struct jbd_revoke_table_s;/* The handle_t type represents a single atomic update being performed * by some process.  All filesystem modifications made by the process go * through this handle.  Recursive operations (such as quota operations) * are gathered into a single update. * * The buffer credits field is used to account for journaled buffers * being modified by the running process.  To ensure that there is * enough log space for all outstanding operations, we need to limit the * number of outstanding buffers possible at any time.  When the * operation completes, any buffer credits not used are credited back to * the transaction, so that at all times we know how many buffers the * outstanding updates on a transaction might possibly touch. */struct handle_s {	/* Which compound transaction is this update a part of? */	transaction_t	      * h_transaction;	/* Number of remaining buffers we are allowed to dirty: */	int			h_buffer_credits;	/* Reference count on this handle */	int			h_ref;	/* Field for caller's use to track errors through large fs	   operations */	int			h_err;	/* List of application registered callbacks for this handle.	 * The function(s) will be called after the transaction that	 * this handle is part of has been committed to disk.	 */	struct list_head	h_jcb;	/* Flags */	unsigned int	h_sync:		1;	/* sync-on-close */	unsigned int	h_jdata:	1;	/* force data journaling */	unsigned int	h_aborted:	1;	/* fatal error on handle */};/* The transaction_t type is the guts of the journaling mechanism.  It * tracks a compound transaction through its various states: * * RUNNING:	accepting new updates * LOCKED:	Updates still running but we don't accept new ones * RUNDOWN:	Updates are tidying up but have finished requesting *		new buffers to modify (state not used for now) * FLUSH:       All updates complete, but we are still writing to disk * COMMIT:      All data on disk, writing commit record * FINISHED:	We still have to keep the transaction for checkpointing. * * The transaction keeps track of all of the buffers modified by a * running transaction, and all of the buffers committed but not yet * flushed to home for finished transactions. */struct transaction_s {	/* Pointer to the journal for this transaction. */	journal_t *		t_journal;		/* Sequence number for this transaction */	tid_t			t_tid;		/* Transaction's current state */	enum {		T_RUNNING,		T_LOCKED,		T_RUNDOWN,		T_FLUSH,		T_COMMIT,		T_FINISHED 	}			t_state;	/* Where in the log does this transaction's commit start? */	unsigned long		t_log_start;		/* Doubly-linked circular list of all inodes owned by this           transaction */	/* AKPM: unused */	struct inode *		t_ilist;		/* Number of buffers on the t_buffers list */	int			t_nr_buffers;		/* Doubly-linked circular list of all buffers reserved but not           yet modified by this transaction */	struct journal_head *	t_reserved_list;		/* Doubly-linked circular list of all metadata buffers owned by this           transaction */	struct journal_head *	t_buffers;		/*	 * Doubly-linked circular list of all data buffers still to be	 * flushed before this transaction can be committed.	 * Protected by journal_datalist_lock.	 */	struct journal_head *	t_sync_datalist;		/*	 * Doubly-linked circular list of all writepage data buffers	 * still to be written before this transaction can be committed.	 * Protected by journal_datalist_lock.	 */	struct journal_head *	t_async_datalist;		/* Doubly-linked circular list of all forget buffers (superseded           buffers which we can un-checkpoint once this transaction           commits) */	struct journal_head *	t_forget;		/*	 * Doubly-linked circular list of all buffers still to be	 * flushed before this transaction can be checkpointed.	 */	/* Protected by journal_datalist_lock */	struct journal_head *	t_checkpoint_list;		/* Doubly-linked circular list of temporary buffers currently           undergoing IO in the log */	struct journal_head *	t_iobuf_list;		/* Doubly-linked circular list of metadata buffers being           shadowed by log IO.  The IO buffers on the iobuf list and the           shadow buffers on this list match each other one for one at           all times. */	struct journal_head *	t_shadow_list;		/* Doubly-linked circular list of control buffers being written           to the log. */	struct journal_head *	t_log_list;		/* Number of outstanding updates running on this transaction */	int			t_updates;	/* Number of buffers reserved for use by all handles in this	 * transaction handle but not yet modified. */	int			t_outstanding_credits;		/*	 * Forward and backward links for the circular list of all	 * transactions awaiting checkpoint.	 */	/* Protected by journal_datalist_lock */	transaction_t		*t_cpnext, *t_cpprev;	/* When will the transaction expire (become due for commit), in	 * jiffies ? */	unsigned long		t_expires;	/* How many handles used this transaction? */	int t_handle_count;	/* List of registered callback functions for this transaction.	 * Called when the transaction is committed. */	struct list_head	t_jcb;};/* The journal_t maintains all of the journaling state information for a * single filesystem.  It is linked to from the fs superblock structure. *  * We use the journal_t to keep track of all outstanding transaction * activity on the filesystem, and to manage the state of the log * writing process. */struct journal_s{	/* General journaling state flags */	unsigned long		j_flags;	/* Is there an outstanding uncleared error on the journal (from	 * a prior abort)? */	int			j_errno;		/* The superblock buffer */	struct buffer_head *	j_sb_buffer;	journal_superblock_t *	j_superblock;	/* Version of the superblock format */	int			j_format_version;	/* Number of processes waiting to create a barrier lock */	int			j_barrier_count;		/* The barrier lock itself */	struct semaphore	j_barrier;	

⌨️ 快捷键说明

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