Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
journal.c File Reference
#include <linux/module.h>
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/jbd2.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/freezer.h>
#include <linux/pagemap.h>
#include <linux/kthread.h>
#include <linux/poison.h>
#include <linux/proc_fs.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/math64.h>
#include <linux/hash.h>
#include <linux/log2.h>
#include <linux/vmalloc.h>
#include <linux/backing-dev.h>
#include <linux/bitops.h>
#include <linux/ratelimit.h>
#include <trace/events/jbd2.h>
#include <asm/uaccess.h>
#include <asm/page.h>

Go to the source code of this file.

Data Structures

struct  jbd2_stats_proc_session
 

Macros

#define CREATE_TRACE_POINTS
 
#define MIN_LOG_RESERVED_BLOCKS   32 /* Allow for rounding errors */
 
#define INCOMPAT_FEATURE_ON(f)   ((incompat & (f)) && !(sb->s_feature_incompat & cpu_to_be32(f)))
 
#define COMPAT_FEATURE_ON(f)   ((compat & (f)) && !(sb->s_feature_compat & cpu_to_be32(f)))
 
#define JBD2_MAX_SLABS   8
 
#define jbd2_create_jbd_stats_proc_entry()   do {} while (0)
 
#define jbd2_remove_jbd_stats_proc_entry()   do {} while (0)
 

Functions

 EXPORT_SYMBOL (jbd2_journal_extend)
 
 EXPORT_SYMBOL (jbd2_journal_stop)
 
 EXPORT_SYMBOL (jbd2_journal_lock_updates)
 
 EXPORT_SYMBOL (jbd2_journal_unlock_updates)
 
 EXPORT_SYMBOL (jbd2_journal_get_write_access)
 
 EXPORT_SYMBOL (jbd2_journal_get_create_access)
 
 EXPORT_SYMBOL (jbd2_journal_get_undo_access)
 
 EXPORT_SYMBOL (jbd2_journal_set_triggers)
 
 EXPORT_SYMBOL (jbd2_journal_dirty_metadata)
 
 EXPORT_SYMBOL (jbd2_journal_release_buffer)
 
 EXPORT_SYMBOL (jbd2_journal_forget)
 
 EXPORT_SYMBOL (jbd2_journal_flush)
 
 EXPORT_SYMBOL (jbd2_journal_revoke)
 
 EXPORT_SYMBOL (jbd2_journal_init_dev)
 
 EXPORT_SYMBOL (jbd2_journal_init_inode)
 
 EXPORT_SYMBOL (jbd2_journal_check_used_features)
 
 EXPORT_SYMBOL (jbd2_journal_check_available_features)
 
 EXPORT_SYMBOL (jbd2_journal_set_features)
 
 EXPORT_SYMBOL (jbd2_journal_load)
 
 EXPORT_SYMBOL (jbd2_journal_destroy)
 
 EXPORT_SYMBOL (jbd2_journal_abort)
 
 EXPORT_SYMBOL (jbd2_journal_errno)
 
 EXPORT_SYMBOL (jbd2_journal_ack_err)
 
 EXPORT_SYMBOL (jbd2_journal_clear_err)
 
 EXPORT_SYMBOL (jbd2_log_wait_commit)
 
 EXPORT_SYMBOL (jbd2_log_start_commit)
 
 EXPORT_SYMBOL (jbd2_journal_start_commit)
 
 EXPORT_SYMBOL (jbd2_journal_force_commit_nested)
 
 EXPORT_SYMBOL (jbd2_journal_wipe)
 
 EXPORT_SYMBOL (jbd2_journal_blocks_per_page)
 
 EXPORT_SYMBOL (jbd2_journal_invalidatepage)
 
 EXPORT_SYMBOL (jbd2_journal_try_to_free_buffers)
 
 EXPORT_SYMBOL (jbd2_journal_force_commit)
 
 EXPORT_SYMBOL (jbd2_journal_file_inode)
 
 EXPORT_SYMBOL (jbd2_journal_init_jbd_inode)
 
 EXPORT_SYMBOL (jbd2_journal_release_jbd_inode)
 
 EXPORT_SYMBOL (jbd2_journal_begin_ordered_truncate)
 
 EXPORT_SYMBOL (jbd2_inode_cache)
 
int jbd2_verify_csum_type (journal_t *j, journal_superblock_t *sb)
 
int jbd2_superblock_csum_verify (journal_t *j, journal_superblock_t *sb)
 
void jbd2_superblock_csum_set (journal_t *j, journal_superblock_t *sb)
 
int jbd2_journal_write_metadata_buffer (transaction_t *transaction, struct journal_head *jh_in, struct journal_head **jh_out, unsigned long long blocknr)
 
int __jbd2_log_space_left (journal_t *journal)
 
int __jbd2_log_start_commit (journal_t *journal, tid_t target)
 
int jbd2_log_start_commit (journal_t *journal, tid_t tid)
 
int jbd2_journal_force_commit_nested (journal_t *journal)
 
int jbd2_journal_start_commit (journal_t *journal, tid_t *ptid)
 
int jbd2_trans_will_send_data_barrier (journal_t *journal, tid_t tid)
 
 EXPORT_SYMBOL (jbd2_trans_will_send_data_barrier)
 
int jbd2_log_wait_commit (journal_t *journal, tid_t tid)
 
int jbd2_journal_next_log_block (journal_t *journal, unsigned long long *retp)
 
int jbd2_journal_bmap (journal_t *journal, unsigned long blocknr, unsigned long long *retp)
 
struct journal_headjbd2_journal_get_descriptor_buffer (journal_t *journal)
 
int jbd2_journal_get_log_tail (journal_t *journal, tid_t *tid, unsigned long *block)
 
void __jbd2_update_log_tail (journal_t *journal, tid_t tid, unsigned long block)
 
void jbd2_update_log_tail (journal_t *journal, tid_t tid, unsigned long block)
 
journal_t * jbd2_journal_init_dev (struct block_device *bdev, struct block_device *fs_dev, unsigned long long start, int len, int blocksize)
 
journal_t * jbd2_journal_init_inode (struct inode *inode)
 
void jbd2_journal_update_sb_log_tail (journal_t *journal, tid_t tail_tid, unsigned long tail_block, int write_op)
 
void jbd2_journal_update_sb_errno (journal_t *journal)
 
 EXPORT_SYMBOL (jbd2_journal_update_sb_errno)
 
int jbd2_journal_load (journal_t *journal)
 
int jbd2_journal_destroy (journal_t *journal)
 
int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
int jbd2_journal_check_available_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
int jbd2_journal_set_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
void jbd2_journal_clear_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
 EXPORT_SYMBOL (jbd2_journal_clear_features)
 
int jbd2_journal_flush (journal_t *journal)
 
int jbd2_journal_wipe (journal_t *journal, int write)
 
void __jbd2_journal_abort_hard (journal_t *journal)
 
void jbd2_journal_abort (journal_t *journal, int errno)
 
int jbd2_journal_errno (journal_t *journal)
 
int jbd2_journal_clear_err (journal_t *journal)
 
void jbd2_journal_ack_err (journal_t *journal)
 
int jbd2_journal_blocks_per_page (struct inode *inode)
 
size_t journal_tag_bytes (journal_t *journal)
 
voidjbd2_alloc (size_t size, gfp_t flags)
 
void jbd2_free (void *ptr, size_t size)
 
struct journal_headjbd2_journal_add_journal_head (struct buffer_head *bh)
 
struct journal_headjbd2_journal_grab_journal_head (struct buffer_head *bh)
 
void jbd2_journal_put_journal_head (struct journal_head *jh)
 
void jbd2_journal_init_jbd_inode (struct jbd2_inode *jinode, struct inode *inode)
 
void jbd2_journal_release_jbd_inode (journal_t *journal, struct jbd2_inode *jinode)
 
 MODULE_LICENSE ("GPL")
 
 module_init (journal_init)
 
 module_exit (journal_exit)
 

Variables

struct kmem_cachejbd2_handle_cache
 
struct kmem_cachejbd2_inode_cache
 

Macro Definition Documentation

#define COMPAT_FEATURE_ON (   f)    ((compat & (f)) && !(sb->s_feature_compat & cpu_to_be32(f)))
#define CREATE_TRACE_POINTS

Definition at line 48 of file journal.c.

#define INCOMPAT_FEATURE_ON (   f)    ((incompat & (f)) && !(sb->s_feature_incompat & cpu_to_be32(f)))
#define jbd2_create_jbd_stats_proc_entry ( )    do {} while (0)

Definition at line 2546 of file journal.c.

#define JBD2_MAX_SLABS   8

Definition at line 2133 of file journal.c.

#define jbd2_remove_jbd_stats_proc_entry ( )    do {} while (0)

Definition at line 2547 of file journal.c.

#define MIN_LOG_RESERVED_BLOCKS   32 /* Allow for rounding errors */

Function Documentation

void __jbd2_journal_abort_hard ( journal_t *  journal)

Definition at line 1952 of file journal.c.

int __jbd2_log_space_left ( journal_t *  journal)

Definition at line 490 of file journal.c.

int __jbd2_log_start_commit ( journal_t *  journal,
tid_t  target 
)

Definition at line 515 of file journal.c.

void __jbd2_update_log_tail ( journal_t *  journal,
tid_t  tid,
unsigned long  block 
)

Definition at line 832 of file journal.c.

EXPORT_SYMBOL ( jbd2_journal_extend  )
EXPORT_SYMBOL ( jbd2_journal_stop  )
EXPORT_SYMBOL ( jbd2_journal_lock_updates  )
EXPORT_SYMBOL ( jbd2_journal_unlock_updates  )
EXPORT_SYMBOL ( jbd2_journal_get_write_access  )
EXPORT_SYMBOL ( jbd2_journal_get_create_access  )
EXPORT_SYMBOL ( jbd2_journal_get_undo_access  )
EXPORT_SYMBOL ( jbd2_journal_set_triggers  )
EXPORT_SYMBOL ( jbd2_journal_dirty_metadata  )
EXPORT_SYMBOL ( jbd2_journal_release_buffer  )
EXPORT_SYMBOL ( jbd2_journal_forget  )
EXPORT_SYMBOL ( jbd2_journal_flush  )
EXPORT_SYMBOL ( jbd2_journal_revoke  )
EXPORT_SYMBOL ( jbd2_journal_init_dev  )
EXPORT_SYMBOL ( jbd2_journal_init_inode  )
EXPORT_SYMBOL ( jbd2_journal_check_used_features  )
EXPORT_SYMBOL ( jbd2_journal_set_features  )
EXPORT_SYMBOL ( jbd2_journal_load  )
EXPORT_SYMBOL ( jbd2_journal_destroy  )
EXPORT_SYMBOL ( jbd2_journal_abort  )
EXPORT_SYMBOL ( jbd2_journal_errno  )
EXPORT_SYMBOL ( jbd2_journal_ack_err  )
EXPORT_SYMBOL ( jbd2_journal_clear_err  )
EXPORT_SYMBOL ( jbd2_log_wait_commit  )
EXPORT_SYMBOL ( jbd2_log_start_commit  )
EXPORT_SYMBOL ( jbd2_journal_start_commit  )
EXPORT_SYMBOL ( jbd2_journal_force_commit_nested  )
EXPORT_SYMBOL ( jbd2_journal_wipe  )
EXPORT_SYMBOL ( jbd2_journal_blocks_per_page  )
EXPORT_SYMBOL ( jbd2_journal_invalidatepage  )
EXPORT_SYMBOL ( jbd2_journal_try_to_free_buffers  )
EXPORT_SYMBOL ( jbd2_journal_force_commit  )
EXPORT_SYMBOL ( jbd2_journal_file_inode  )
EXPORT_SYMBOL ( jbd2_journal_init_jbd_inode  )
EXPORT_SYMBOL ( jbd2_journal_release_jbd_inode  )
EXPORT_SYMBOL ( jbd2_inode_cache  )
EXPORT_SYMBOL ( jbd2_trans_will_send_data_barrier  )
EXPORT_SYMBOL ( jbd2_journal_update_sb_errno  )
EXPORT_SYMBOL ( jbd2_journal_clear_features  )
void* jbd2_alloc ( size_t  size,
gfp_t  flags 
)

Definition at line 2195 of file journal.c.

void jbd2_free ( void ptr,
size_t  size 
)

Definition at line 2221 of file journal.c.

void jbd2_journal_abort ( journal_t *  journal,
int  errno 
)

void jbd2_journal_abort () - Shutdown the journal immediately. : the journal to shutdown. : an error number to record in the journal indicating the reason for the shutdown.

Perform a complete, immediate shutdown of the ENTIRE journal (not of a single transaction). This operation cannot be undone without closing and reopening the journal.

The jbd2_journal_abort function is intended to support higher level error recovery mechanisms such as the ext2/ext3 remount-readonly error mode.

Journal abort has very specific semantics. Any existing dirty, unjournaled buffers in the main filesystem will still be written to disk by bdflush, but the journaling mechanism will be suspended immediately and no further transaction commits will be honoured.

Any dirty, journaled buffers will be written back to disk without hitting the journal. Atomicity cannot be guaranteed on an aborted filesystem, but we do attempt to leave as much data as possible behind for fsck to use for cleanup.

Any attempt to get a new transaction handle on a journal which is in ABORT state will just result in an -EROFS error return. A jbd2_journal_stop on an existing handle will return -EIO if we have entered abort state during the update.

Recursive transactions are not disturbed by journal abort until the final jbd2_journal_stop, which will receive the -EIO error.

Finally, the jbd2_journal_abort call allows the caller to supply an errno which will be recorded (if possible) in the journal superblock. This allows a client to record failure conditions in the middle of a transaction without having to complete the transaction to record the failure to disk. ext3_error, for example, now uses this functionality.

Errors which originate from within the journaling layer will NOT supply an errno; a null errno implies that absolutely no further writes are done to the journal (unless there are any already in progress).

Definition at line 2032 of file journal.c.

void jbd2_journal_ack_err ( journal_t *  journal)

void jbd2_journal_ack_err() - Ack journal err. : journal to act on.

An error must be cleared or acked to take a FS out of readonly mode.

Definition at line 2088 of file journal.c.

struct journal_head* jbd2_journal_add_journal_head ( struct buffer_head *  bh)
read

Definition at line 2345 of file journal.c.

int jbd2_journal_blocks_per_page ( struct inode inode)

Definition at line 2096 of file journal.c.

int jbd2_journal_bmap ( journal_t *  journal,
unsigned long  blocknr,
unsigned long long retp 
)

Definition at line 728 of file journal.c.

int jbd2_journal_check_available_features ( journal_t *  journal,
unsigned long  compat,
unsigned long  ro,
unsigned long  incompat 
)

int jbd2_journal_check_available_features() - Check feature set in journalling layer : Journal to check. : bitmask of compatible features : bitmask of features that force read-only mount : bitmask of incompatible features

Check whether the journaling code supports the use of all of a given set of features on this journal. Return true (non-zero) if it can.

Definition at line 1706 of file journal.c.

int jbd2_journal_check_used_features ( journal_t *  journal,
unsigned long  compat,
unsigned long  ro,
unsigned long  incompat 
)

*int jbd2_journal_check_used_features () - Check if features specified are used. : Journal to check. : bitmask of compatible features : bitmask of features that force read-only mount : bitmask of incompatible features

Check whether the journal uses all of a given set of features. Return true (non-zero) if it does.

Definition at line 1671 of file journal.c.

int jbd2_journal_clear_err ( journal_t *  journal)

int jbd2_journal_clear_err () - clears the journal's error state : journal to act on.

An error must be cleared or acked to take a FS out of readonly mode.

Definition at line 2068 of file journal.c.

void jbd2_journal_clear_features ( journal_t *  journal,
unsigned long  compat,
unsigned long  ro,
unsigned long  incompat 
)

Definition at line 1815 of file journal.c.

int jbd2_journal_destroy ( journal_t *  journal)

void jbd2_journal_destroy() - Release a journal_t structure. : Journal to act on.

Release a journal_t structure once it is no longer in use by the journaled object. Return <0 if we couldn't clean up the journal.

Definition at line 1607 of file journal.c.

int jbd2_journal_errno ( journal_t *  journal)

int jbd2_journal_errno () - returns the journal's error state. : journal to examine.

This is the errno number set with jbd2_journal_abort(), the last time the journal was mounted - if the journal was stopped without calling abort this will be 0.

If the journal has been aborted on this mount time -EROFS will be returned.

Definition at line 2048 of file journal.c.

int jbd2_journal_flush ( journal_t *  journal)

int jbd2_journal_flush () - Flush journal : Journal to act on.

Flush all data for a given journal to disk and empty the journal. Filesystems can use this when remounting readonly to ensure that recovery does not need to happen on remount.

Definition at line 1840 of file journal.c.

int jbd2_journal_force_commit_nested ( journal_t *  journal)

Definition at line 567 of file journal.c.

struct journal_head* jbd2_journal_get_descriptor_buffer ( journal_t *  journal)
read

Definition at line 761 of file journal.c.

int jbd2_journal_get_log_tail ( journal_t *  journal,
tid_t tid,
unsigned long block 
)

Definition at line 793 of file journal.c.

struct journal_head* jbd2_journal_grab_journal_head ( struct buffer_head *  bh)
read

Definition at line 2388 of file journal.c.

journal_t* jbd2_journal_init_dev ( struct block_device bdev,
struct block_device fs_dev,
unsigned long long  start,
int  len,
int  blocksize 
)

journal_t * jbd2_journal_init_dev() - creates and initialises a journal structure : Block device on which to create the journal : Device which hold journalled filesystem for this journal. : Block nr Start of journal. : Length of the journal in blocks. : blocksize of journalling device

Returns: a newly created journal_t *

jbd2_journal_init_dev creates a journal which maps a fixed contiguous range of blocks on an arbitrary block device.

Definition at line 1073 of file journal.c.

journal_t* jbd2_journal_init_inode ( struct inode inode)

journal_t * jbd2_journal_init_inode () - creates a journal which maps to a inode. : An inode to create the journal in

jbd2_journal_init_inode creates a journal which maps an on-disk inode as the journal. The inode must exist already, must support bmap() and must have all data blocks preallocated.

Definition at line 1131 of file journal.c.

void jbd2_journal_init_jbd_inode ( struct jbd2_inode *  jinode,
struct inode inode 
)

Definition at line 2449 of file journal.c.

int jbd2_journal_load ( journal_t *  journal)

int jbd2_journal_load() - Read journal from disk. : Journal to act on.

Given a journal_t structure which tells us which disk blocks contain a journal, read the journal from disk to initialise the in-memory structures.

Definition at line 1541 of file journal.c.

int jbd2_journal_next_log_block ( journal_t *  journal,
unsigned long long retp 
)

Definition at line 705 of file journal.c.

void jbd2_journal_put_journal_head ( struct journal_head jh)

Definition at line 2431 of file journal.c.

void jbd2_journal_release_jbd_inode ( journal_t *  journal,
struct jbd2_inode *  jinode 
)

Definition at line 2463 of file journal.c.

int jbd2_journal_set_features ( journal_t *  journal,
unsigned long  compat,
unsigned long  ro,
unsigned long  incompat 
)

int jbd2_journal_set_features () - Mark a given journal feature in the superblock : Journal to act on. : bitmask of compatible features : bitmask of features that force read-only mount : bitmask of incompatible features

Mark a given journal feature as present on the superblock. Returns true if the requested features could be set.

Definition at line 1739 of file journal.c.

int jbd2_journal_start_commit ( journal_t *  journal,
tid_t ptid 
)

Definition at line 599 of file journal.c.

void jbd2_journal_update_sb_errno ( journal_t *  journal)

jbd2_journal_update_sb_errno() - Update error in the journal. : The journal to update.

Update a journal's errno. Write updated superblock to disk waiting for IO to complete.

Definition at line 1385 of file journal.c.

void jbd2_journal_update_sb_log_tail ( journal_t *  journal,
tid_t  tail_tid,
unsigned long  tail_block,
int  write_op 
)

jbd2_journal_update_sb_log_tail() - Update log tail in journal sb on disk. : The journal to update. : TID of the new transaction at the tail of the log : The first block of the transaction at the tail of the log : With which operation should we write the journal sb

Update a journal's superblock information about log tail and write it to disk, waiting for the IO to complete.

Definition at line 1323 of file journal.c.

int jbd2_journal_wipe ( journal_t *  journal,
int  write 
)

int jbd2_journal_wipe() - Wipe journal contents : Journal to act on. : flag (see below)

Wipe out all of the contents of a journal, safely. This will produce a warning if the journal contains any valid recovery information. Must be called between journal_init_*() and jbd2_journal_load().

If 'write' is non-zero, then we wipe out the journal on disk; otherwise we merely suppress recovery.

Definition at line 1911 of file journal.c.

int jbd2_journal_write_metadata_buffer ( transaction_t transaction,
struct journal_head jh_in,
struct journal_head **  jh_out,
unsigned long long  blocknr 
)

Definition at line 325 of file journal.c.

int jbd2_log_start_commit ( journal_t *  journal,
tid_t  tid 
)

Definition at line 547 of file journal.c.

int jbd2_log_wait_commit ( journal_t *  journal,
tid_t  tid 
)

Definition at line 671 of file journal.c.

void jbd2_superblock_csum_set ( journal_t *  j,
journal_superblock_t sb 
)

Definition at line 129 of file journal.c.

int jbd2_superblock_csum_verify ( journal_t *  j,
journal_superblock_t sb 
)

Definition at line 121 of file journal.c.

int jbd2_trans_will_send_data_barrier ( journal_t *  journal,
tid_t  tid 
)

Definition at line 632 of file journal.c.

void jbd2_update_log_tail ( journal_t *  journal,
tid_t  tid,
unsigned long  block 
)

Definition at line 867 of file journal.c.

int jbd2_verify_csum_type ( journal_t *  j,
journal_superblock_t sb 
)

Definition at line 101 of file journal.c.

size_t journal_tag_bytes ( journal_t *  journal)

Definition at line 2104 of file journal.c.

module_exit ( journal_exit  )
module_init ( journal_init  )
MODULE_LICENSE ( "GPL"  )

Variable Documentation

struct kmem_cache* jbd2_handle_cache

Definition at line 2551 of file journal.c.

struct kmem_cache * jbd2_inode_cache

Definition at line 2551 of file journal.c.