Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
transaction.c File Reference
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/jbd2.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/hrtimer.h>
#include <linux/backing-dev.h>
#include <linux/bug.h>
#include <linux/module.h>

Go to the source code of this file.

Functions

int __init jbd2_journal_init_transaction_cache (void)
 
void jbd2_journal_destroy_transaction_cache (void)
 
void jbd2_journal_free_transaction (transaction_t *transaction)
 
handle_t * jbd2__journal_start (journal_t *journal, int nblocks, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (jbd2__journal_start)
 
handle_t * jbd2_journal_start (journal_t *journal, int nblocks)
 
 EXPORT_SYMBOL (jbd2_journal_start)
 
int jbd2_journal_extend (handle_t *handle, int nblocks)
 
int jbd2__journal_restart (handle_t *handle, int nblocks, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (jbd2__journal_restart)
 
int jbd2_journal_restart (handle_t *handle, int nblocks)
 
 EXPORT_SYMBOL (jbd2_journal_restart)
 
void jbd2_journal_lock_updates (journal_t *journal)
 
void jbd2_journal_unlock_updates (journal_t *journal)
 
int jbd2_journal_get_write_access (handle_t *handle, struct buffer_head *bh)
 
int jbd2_journal_get_create_access (handle_t *handle, struct buffer_head *bh)
 
int jbd2_journal_get_undo_access (handle_t *handle, struct buffer_head *bh)
 
void jbd2_journal_set_triggers (struct buffer_head *bh, struct jbd2_buffer_trigger_type *type)
 
void jbd2_buffer_frozen_trigger (struct journal_head *jh, void *mapped_data, struct jbd2_buffer_trigger_type *triggers)
 
void jbd2_buffer_abort_trigger (struct journal_head *jh, struct jbd2_buffer_trigger_type *triggers)
 
int jbd2_journal_dirty_metadata (handle_t *handle, struct buffer_head *bh)
 
void jbd2_journal_release_buffer (handle_t *handle, struct buffer_head *bh)
 
int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
 
int jbd2_journal_stop (handle_t *handle)
 
int jbd2_journal_force_commit (journal_t *journal)
 
void jbd2_journal_unfile_buffer (journal_t *journal, struct journal_head *jh)
 
int jbd2_journal_try_to_free_buffers (journal_t *journal, struct page *page, gfp_t gfp_mask)
 
void jbd2_journal_invalidatepage (journal_t *journal, struct page *page, unsigned long offset)
 
void __jbd2_journal_file_buffer (struct journal_head *jh, transaction_t *transaction, int jlist)
 
void jbd2_journal_file_buffer (struct journal_head *jh, transaction_t *transaction, int jlist)
 
void __jbd2_journal_refile_buffer (struct journal_head *jh)
 
void jbd2_journal_refile_buffer (journal_t *journal, struct journal_head *jh)
 
int jbd2_journal_file_inode (handle_t *handle, struct jbd2_inode *jinode)
 
int jbd2_journal_begin_ordered_truncate (journal_t *journal, struct jbd2_inode *jinode, loff_t new_size)
 

Function Documentation

void __jbd2_journal_file_buffer ( struct journal_head jh,
transaction_t transaction,
int  jlist 
)

Definition at line 2062 of file transaction.c.

void __jbd2_journal_refile_buffer ( struct journal_head jh)

Definition at line 2155 of file transaction.c.

EXPORT_SYMBOL ( jbd2__journal_start  )
EXPORT_SYMBOL ( jbd2_journal_start  )
EXPORT_SYMBOL ( jbd2__journal_restart  )
EXPORT_SYMBOL ( jbd2_journal_restart  )
int jbd2__journal_restart ( handle_t *  handle,
int  nblocks,
gfp_t  gfp_mask 
)

int jbd2_journal_restart() - restart a handle . : handle to restart : nr credits requested

Restart a handle for a multi-transaction filesystem operation.

If the jbd2_journal_extend() call above fails to grant new buffer credits to a running handle, a call to jbd2_journal_restart will commit the handle's transaction so far and reattach the handle to a new transaction capabable of guaranteeing the requested number of credits.

Definition at line 477 of file transaction.c.

handle_t* jbd2__journal_start ( journal_t *  journal,
int  nblocks,
gfp_t  gfp_mask 
)

handle_t *jbd2_journal_start() - Obtain a new handle. : Journal to start transaction on. : number of block buffer we might modify

We make sure that the transaction can guarantee at least nblocks of modified buffers in the log. We block until the log can guarantee that much space.

This function is visible to journal users (like ext3fs), so is not called with the journal already locked.

Return a pointer to a newly allocated handle, or an ERR_PTR() value on failure.

Definition at line 354 of file transaction.c.

void jbd2_buffer_abort_trigger ( struct journal_head jh,
struct jbd2_buffer_trigger_type *  triggers 
)

Definition at line 1065 of file transaction.c.

void jbd2_buffer_frozen_trigger ( struct journal_head jh,
void mapped_data,
struct jbd2_buffer_trigger_type *  triggers 
)

Definition at line 1054 of file transaction.c.

int jbd2_journal_begin_ordered_truncate ( journal_t *  journal,
struct jbd2_inode *  jinode,
loff_t  new_size 
)

Definition at line 2300 of file transaction.c.

void jbd2_journal_destroy_transaction_cache ( void  )

Definition at line 50 of file transaction.c.

int jbd2_journal_dirty_metadata ( handle_t *  handle,
struct buffer_head *  bh 
)

int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata : transaction to add buffer to. : buffer to mark

mark dirty metadata which needs to be journaled as part of the current transaction.

The buffer must have previously had jbd2_journal_get_write_access() called so that it has a valid journal_head attached to the buffer head.

The buffer is placed on the transaction's metadata list and is marked as belonging to the transaction.

Returns error number or 0 on success.

Special care needs to be taken if the buffer already belongs to the current committing transaction (in which case we should have frozen data present for that commit). In that case, we don't relink the buffer: that only gets done when the old transaction finally completes its commit.

Definition at line 1099 of file transaction.c.

int jbd2_journal_extend ( handle_t *  handle,
int  nblocks 
)

int jbd2_journal_extend() - extend buffer credits. : handle to 'extend' : nr blocks to try to extend by.

Some transactions, such as large extends and truncates, can be done atomically all at once or in several stages. The operation requests a credit for a number of buffer modications in advance, but can extend its credit if it needs more.

jbd2_journal_extend tries to give the running handle more buffer credits. It does not guarantee that allocation - this is a best-effort only. The calling process MUST be able to deal cleanly with a failure to extend here.

Return 0 on success, non-zero on failure.

return code < 0 implies an error return code > 0 implies normal transaction-full status.

Definition at line 412 of file transaction.c.

void jbd2_journal_file_buffer ( struct journal_head jh,
transaction_t transaction,
int  jlist 
)

Definition at line 2134 of file transaction.c.

int jbd2_journal_file_inode ( handle_t *  handle,
struct jbd2_inode *  jinode 
)

Definition at line 2220 of file transaction.c.

int jbd2_journal_force_commit ( journal_t *  journal)

int jbd2_journal_force_commit() - force any uncommitted transactions : journal to force

For synchronous operations: force any uncommitted transactions to disk. May seem kludgy, but it reuses all the handle batching code in a very simple manner.

Definition at line 1506 of file transaction.c.

int jbd2_journal_forget ( handle_t *  handle,
struct buffer_head *  bh 
)

void jbd2_journal_forget() - bforget() for potentially-journaled buffers. : transaction handle : bh to 'forget'

We can only do the bforget if there are no commits pending against the buffer. If the buffer is dirty in the current running transaction we can safely unlink it.

bh may not be a journalled buffer at all - it may be a non-JBD buffer which came off the hashtable. Check for this.

Decrements bh->b_count by one.

Allow this call even if the handle has aborted — it may be part of the caller's cleanup after an abort.

Definition at line 1238 of file transaction.c.

void jbd2_journal_free_transaction ( transaction_t transaction)

Definition at line 58 of file transaction.c.

int jbd2_journal_get_create_access ( handle_t *  handle,
struct buffer_head *  bh 
)

int jbd2_journal_get_create_access () - notify intent to use newly created bh : transaction to new buffer to : new buffer.

Call this if you create a new bh.

Definition at line 889 of file transaction.c.

int jbd2_journal_get_undo_access ( handle_t *  handle,
struct buffer_head *  bh 
)

int jbd2_journal_get_undo_access() - Notify intent to modify metadata with non-rewindable consequences : transaction : buffer to undo

Sometimes there is a need to distinguish between metadata which has been committed to disk and that which has not. The ext3fs code uses this for freeing and allocating space, we have to make sure that we do not reuse freed space until the deallocation has been committed, since if we overwrote that space we would make the delete un-rewindable in case of a crash.

To deal with that, jbd2_journal_get_undo_access requests write access to a buffer for parts of non-rewindable operations such as delete operations on the bitmaps. The journaling code must keep a copy of the buffer's contents prior to the undo_access call until such time as we know that the buffer has definitely been committed to disk.

We never need to know which transaction the committed data is part of, buffers touched here are guaranteed to be dirtied later and so will be committed to a new transaction in due course, at which point we can discard the old committed data pointer.

Returns error number or 0 on success.

Definition at line 985 of file transaction.c.

int jbd2_journal_get_write_access ( handle_t *  handle,
struct buffer_head *  bh 
)

int jbd2_journal_get_write_access() - notify intent to modify a buffer for metadata (not data) update. : transaction to add buffer modifications to : bh to be used for metadata writes

Returns an error code or 0 on success.

In full data journalling mode the buffer may be of type BJ_AsyncData, because we're write()ing a buffer which is also part of a shared mapping.

Definition at line 856 of file transaction.c.

int __init jbd2_journal_init_transaction_cache ( void  )

Definition at line 37 of file transaction.c.

void jbd2_journal_invalidatepage ( journal_t *  journal,
struct page page,
unsigned long  offset 
)

Definition at line 2019 of file transaction.c.

void jbd2_journal_lock_updates ( journal_t *  journal)

void jbd2_journal_lock_updates () - establish a transaction barrier. : Journal to establish a barrier on.

This locks out any further updates from being started, and blocks until all existing updates have completed, returning only once the journal is in a quiescent state with no updates running.

The journal lock should not be held on entry.

Definition at line 535 of file transaction.c.

void jbd2_journal_refile_buffer ( journal_t *  journal,
struct journal_head jh 
)

Definition at line 2203 of file transaction.c.

void jbd2_journal_release_buffer ( handle_t *  handle,
struct buffer_head *  bh 
)

Definition at line 1216 of file transaction.c.

int jbd2_journal_restart ( handle_t *  handle,
int  nblocks 
)

Definition at line 519 of file transaction.c.

void jbd2_journal_set_triggers ( struct buffer_head *  bh,
struct jbd2_buffer_trigger_type *  type 
)

void jbd2_journal_set_triggers() - Add triggers for commit writeout : buffer to trigger on : struct jbd2_buffer_trigger_type containing the trigger(s).

Set any triggers on this journal_head. This is always safe, because triggers for a committing buffer will be saved off, and triggers for a running transaction will match the buffer in that transaction.

Call with NULL to clear the triggers.

Definition at line 1046 of file transaction.c.

handle_t* jbd2_journal_start ( journal_t *  journal,
int  nblocks 
)

Definition at line 385 of file transaction.c.

int jbd2_journal_stop ( handle_t *  handle)

int jbd2_journal_stop() - complete a transaction : tranaction to complete.

All done for a particular handle.

There is not much action needed here. We just return any remaining buffer credits to the transaction and remove the handle. The only complication is that we need to start a commit operation if the filesystem is marked for synchronous update.

jbd2_journal_stop itself will not usually return an error, but it may do so in unusual circumstances. In particular, expect it to return -EIO if a jbd2_journal_abort has been executed since the transaction began.

Definition at line 1365 of file transaction.c.

int jbd2_journal_try_to_free_buffers ( journal_t *  journal,
struct page page,
gfp_t  gfp_mask 
)

Definition at line 1725 of file transaction.c.

void jbd2_journal_unfile_buffer ( journal_t *  journal,
struct journal_head jh 
)

Definition at line 1644 of file transaction.c.

void jbd2_journal_unlock_updates ( journal_t *  journal)

void jbd2_journal_unlock_updates (journal_t* journal) - release barrier : Journal to release the barrier on.

Release a transaction barrier obtained with jbd2_journal_lock_updates().

Should be called without the journal lock held.

Definition at line 582 of file transaction.c.