Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
journal.c File Reference
#include <linux/module.h>
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/jbd.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/ratelimit.h>
#include <trace/events/jbd.h>
#include <asm/uaccess.h>
#include <asm/page.h>

Go to the source code of this file.

Macros

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

Functions

 EXPORT_SYMBOL (journal_start)
 
 EXPORT_SYMBOL (journal_restart)
 
 EXPORT_SYMBOL (journal_extend)
 
 EXPORT_SYMBOL (journal_stop)
 
 EXPORT_SYMBOL (journal_lock_updates)
 
 EXPORT_SYMBOL (journal_unlock_updates)
 
 EXPORT_SYMBOL (journal_get_write_access)
 
 EXPORT_SYMBOL (journal_get_create_access)
 
 EXPORT_SYMBOL (journal_get_undo_access)
 
 EXPORT_SYMBOL (journal_dirty_data)
 
 EXPORT_SYMBOL (journal_dirty_metadata)
 
 EXPORT_SYMBOL (journal_release_buffer)
 
 EXPORT_SYMBOL (journal_forget)
 
 EXPORT_SYMBOL (journal_flush)
 
 EXPORT_SYMBOL (journal_revoke)
 
 EXPORT_SYMBOL (journal_init_dev)
 
 EXPORT_SYMBOL (journal_init_inode)
 
 EXPORT_SYMBOL (journal_update_format)
 
 EXPORT_SYMBOL (journal_check_used_features)
 
 EXPORT_SYMBOL (journal_check_available_features)
 
 EXPORT_SYMBOL (journal_set_features)
 
 EXPORT_SYMBOL (journal_create)
 
 EXPORT_SYMBOL (journal_load)
 
 EXPORT_SYMBOL (journal_destroy)
 
 EXPORT_SYMBOL (journal_abort)
 
 EXPORT_SYMBOL (journal_errno)
 
 EXPORT_SYMBOL (journal_ack_err)
 
 EXPORT_SYMBOL (journal_clear_err)
 
 EXPORT_SYMBOL (log_wait_commit)
 
 EXPORT_SYMBOL (log_start_commit)
 
 EXPORT_SYMBOL (journal_start_commit)
 
 EXPORT_SYMBOL (journal_force_commit_nested)
 
 EXPORT_SYMBOL (journal_wipe)
 
 EXPORT_SYMBOL (journal_blocks_per_page)
 
 EXPORT_SYMBOL (journal_invalidatepage)
 
 EXPORT_SYMBOL (journal_try_to_free_buffers)
 
 EXPORT_SYMBOL (journal_force_commit)
 
int journal_write_metadata_buffer (transaction_t *transaction, struct journal_head *jh_in, struct journal_head **jh_out, unsigned int blocknr)
 
int __log_space_left (journal_t *journal)
 
int __log_start_commit (journal_t *journal, tid_t target)
 
int log_start_commit (journal_t *journal, tid_t tid)
 
int journal_force_commit_nested (journal_t *journal)
 
int journal_start_commit (journal_t *journal, tid_t *ptid)
 
int log_wait_commit (journal_t *journal, tid_t tid)
 
int journal_trans_will_send_data_barrier (journal_t *journal, tid_t tid)
 
 EXPORT_SYMBOL (journal_trans_will_send_data_barrier)
 
int journal_next_log_block (journal_t *journal, unsigned int *retp)
 
int journal_bmap (journal_t *journal, unsigned int blocknr, unsigned int *retp)
 
struct journal_headjournal_get_descriptor_buffer (journal_t *journal)
 
journal_t * journal_init_dev (struct block_device *bdev, struct block_device *fs_dev, int start, int len, int blocksize)
 
journal_t * journal_init_inode (struct inode *inode)
 
int journal_create (journal_t *journal)
 
void journal_update_sb_log_tail (journal_t *journal, tid_t tail_tid, unsigned int tail_block, int write_op)
 
int journal_load (journal_t *journal)
 
int journal_destroy (journal_t *journal)
 
int journal_check_used_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
int journal_check_available_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
int journal_set_features (journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
 
int journal_update_format (journal_t *journal)
 
int journal_flush (journal_t *journal)
 
int journal_wipe (journal_t *journal, int write)
 
void journal_abort (journal_t *journal, int errno)
 
int journal_errno (journal_t *journal)
 
int journal_clear_err (journal_t *journal)
 
void journal_ack_err (journal_t *journal)
 
int journal_blocks_per_page (struct inode *inode)
 
struct journal_headjournal_add_journal_head (struct buffer_head *bh)
 
struct journal_headjournal_grab_journal_head (struct buffer_head *bh)
 
void journal_put_journal_head (struct journal_head *jh)
 
 MODULE_LICENSE ("GPL")
 
 module_init (journal_init)
 
 module_exit (journal_exit)
 

Variables

struct kmem_cachejbd_handle_cache
 

Macro Definition Documentation

#define CREATE_TRACE_POINTS

Definition at line 41 of file journal.c.

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

Function Documentation

int __log_space_left ( journal_t *  journal)

Definition at line 418 of file journal.c.

int __log_start_commit ( journal_t *  journal,
tid_t  target 
)

Definition at line 442 of file journal.c.

EXPORT_SYMBOL ( journal_start  )
EXPORT_SYMBOL ( journal_restart  )
EXPORT_SYMBOL ( journal_extend  )
EXPORT_SYMBOL ( journal_stop  )
EXPORT_SYMBOL ( journal_lock_updates  )
EXPORT_SYMBOL ( journal_unlock_updates  )
EXPORT_SYMBOL ( journal_get_write_access  )
EXPORT_SYMBOL ( journal_get_create_access  )
EXPORT_SYMBOL ( journal_get_undo_access  )
EXPORT_SYMBOL ( journal_dirty_data  )
EXPORT_SYMBOL ( journal_dirty_metadata  )
EXPORT_SYMBOL ( journal_release_buffer  )
EXPORT_SYMBOL ( journal_forget  )
EXPORT_SYMBOL ( journal_flush  )
EXPORT_SYMBOL ( journal_revoke  )
EXPORT_SYMBOL ( journal_init_dev  )
EXPORT_SYMBOL ( journal_init_inode  )
EXPORT_SYMBOL ( journal_update_format  )
EXPORT_SYMBOL ( journal_check_used_features  )
EXPORT_SYMBOL ( journal_check_available_features  )
EXPORT_SYMBOL ( journal_set_features  )
EXPORT_SYMBOL ( journal_create  )
EXPORT_SYMBOL ( journal_load  )
EXPORT_SYMBOL ( journal_destroy  )
EXPORT_SYMBOL ( journal_abort  )
EXPORT_SYMBOL ( journal_errno  )
EXPORT_SYMBOL ( journal_ack_err  )
EXPORT_SYMBOL ( journal_clear_err  )
EXPORT_SYMBOL ( log_wait_commit  )
EXPORT_SYMBOL ( log_start_commit  )
EXPORT_SYMBOL ( journal_start_commit  )
EXPORT_SYMBOL ( journal_force_commit_nested  )
EXPORT_SYMBOL ( journal_wipe  )
EXPORT_SYMBOL ( journal_blocks_per_page  )
EXPORT_SYMBOL ( journal_invalidatepage  )
EXPORT_SYMBOL ( journal_try_to_free_buffers  )
EXPORT_SYMBOL ( journal_force_commit  )
void journal_abort ( journal_t *  journal,
int  errno 
)

void 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 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 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 journal_stop, which will receive the -EIO error.

Finally, the 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 1734 of file journal.c.

void journal_ack_err ( journal_t *  journal)

void 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 1790 of file journal.c.

struct journal_head* journal_add_journal_head ( struct buffer_head *  bh)
read

Definition at line 1911 of file journal.c.

int journal_blocks_per_page ( struct inode inode)

Definition at line 1798 of file journal.c.

int journal_bmap ( journal_t *  journal,
unsigned int  blocknr,
unsigned int retp 
)

Definition at line 645 of file journal.c.

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

int 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 1403 of file journal.c.

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

*int 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 1372 of file journal.c.

int journal_clear_err ( journal_t *  journal)

int 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 1770 of file journal.c.

int journal_create ( journal_t *  journal)

int journal_create() - Initialise the new journal file : Journal to create. This structure must have been initialised

Given a journal_t structure which tells us which disk blocks we can use, create a new journal superblock and initialise all of the journal fields from scratch.

Definition at line 964 of file journal.c.

int journal_destroy ( journal_t *  journal)

void 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 1310 of file journal.c.

int journal_errno ( journal_t *  journal)

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

This is the errno numbet set with 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 1750 of file journal.c.

int journal_flush ( journal_t *  journal)

int 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 1524 of file journal.c.

int journal_force_commit_nested ( journal_t *  journal)

Definition at line 493 of file journal.c.

struct journal_head* journal_get_descriptor_buffer ( journal_t *  journal)
read

Definition at line 682 of file journal.c.

struct journal_head* journal_grab_journal_head ( struct buffer_head *  bh)
read

Definition at line 1954 of file journal.c.

journal_t* journal_init_dev ( struct block_device bdev,
struct block_device fs_dev,
int  start,
int  len,
int  blocksize 
)

journal_t * 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 *

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

Definition at line 772 of file journal.c.

journal_t* journal_init_inode ( struct inode inode)

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

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 823 of file journal.c.

int journal_load ( journal_t *  journal)

int 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 1258 of file journal.c.

int journal_next_log_block ( journal_t *  journal,
unsigned int retp 
)

Definition at line 622 of file journal.c.

void journal_put_journal_head ( struct journal_head jh)

Definition at line 1997 of file journal.c.

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

int 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 1436 of file journal.c.

int journal_start_commit ( journal_t *  journal,
tid_t ptid 
)

Definition at line 521 of file journal.c.

int journal_trans_will_send_data_barrier ( journal_t *  journal,
tid_t  tid 
)

Definition at line 592 of file journal.c.

int journal_update_format ( journal_t *  journal)

int journal_update_format () - Update on-disk journal structure. : Journal to act on.

Given an initialised but unloaded journal struct, poke about in the on-disk structure to update it to the most recent supported version.

Definition at line 1467 of file journal.c.

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

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 1082 of file journal.c.

int journal_wipe ( journal_t *  journal,
int  write 
)

int 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 journal_load().

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

Definition at line 1595 of file journal.c.

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

Definition at line 284 of file journal.c.

int log_start_commit ( journal_t *  journal,
tid_t  tid 
)

Definition at line 473 of file journal.c.

int log_wait_commit ( journal_t *  journal,
tid_t  tid 
)

Definition at line 552 of file journal.c.

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

Variable Documentation

struct kmem_cache* jbd_handle_cache

Definition at line 2050 of file journal.c.