📄 jbd.h.txt
字号:
any problems, send mails to sindybear@163.com
相关文件
/fs/jbd/*.*
/*
* header结构,用来标记
*/
typedef struct journal_header_s
{
__u32 h_magic;
__u32 h_blocktype;
__u32 h_sequence;
} journal_header_t;
typedef struct journal_block_tag_s
{
__u32 t_blocknr; /* 源数据在原始磁盘上的位置 */
__u32 t_flags; /* See below */
} journal_block_tag_t;
typedef struct journal_superblock_s
{
journal_header_t s_header; /* 用来标记本身这个超级块 */
__u32 s_blocksize; /* 日志设备的块大小 */
__u32 s_maxlen; /* 一共有多少块 */
__u32 s_first; /* 真正的日志区的开始块号 */
__u32 s_sequence; /* first commit ID expected in log */
__u32 s_start; /* 日志的开始块号,也就是日志的tail */
__s32 s_errno;
__u32 s_feature_compat; /* compatible feature set */
__u32 s_feature_incompat; /* incompatible feature set */
__u32 s_feature_ro_compat; /* readonly-compatible feature set */
__u8 s_uuid[16]; /* 128-bit uuid for journal */
__u32 s_nr_users; /* Nr of filesystems sharing log */
__u32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
__u32 s_max_transaction; /* Limit of journal blocks per trans.*/
__u32 s_max_trans_data; /* Limit of data blocks per trans. */
__u32 s_padding[44];
__u8 s_users[16*48]; /* ids of all fs'es sharing the log */
} journal_superblock_t;
struct transaction_s
{
journal_t * t_journal; //包含这个transaction的journal
tid_t t_tid; //transaction的sequence number
enum {
T_RUNNING,
T_LOCKED,
T_RUNDOWN,
T_FLUSH,
T_COMMIT,
T_FINISHED
} t_state; //这个事务的状态
unsigned long t_log_start; //这个事务在日志区的开始位置
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 (superceded
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;
};
#define BJ_None 0 /* Not journaled */
#define BJ_SyncData 1 /* Normal data: flush before commit */
#define BJ_AsyncData 2 /* writepage data: wait on it before commit */
#define BJ_Metadata 3 /* 原数据日志 */
#define BJ_Forget 4 /* Buffer superceded by this transaction */
#define BJ_IO 5 /* 临时使用的 */
#define BJ_Shadow 6 /* 和BJ_IO一一对应,也就是说在他是BJ_IO的影子 */
#define BJ_LogCtl 7 /* 表明是日志的descriptor */
#define BJ_Reserved 8 /* Buffer is reserved for access by journal */
得到当前进程所处的日志
static inline handle_t *journal_current_handle(void)
return current->journal_info;
锁定日志
static inline void lock_journal(journal_t *journal)
down(&journal->j_sem);
解锁日志
static inline void unlock_journal(journal_t * journal)
up(&journal->j_sem);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -