Commit 2ac28750 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ext3: Remove journal_try_start()

journal_try_start() is a function which nonblockingly attempts to open a JBD
transaction handle.  It was added a long time ago when there were concerns
that ext3_writepage() could block kswapd for too long.

It was never clearly necessary.

So the patch throws it all away and just calls the blocking journal_start()
from ext3_writepage().
parent 537ca630
......@@ -1317,10 +1317,7 @@ static int ext3_writepage(struct page *page, struct writeback_control *wbc)
goto out_fail;
needed = ext3_writepage_trans_blocks(inode);
if (wbc->for_reclaim)
handle = ext3_journal_try_start(inode, needed);
else
handle = ext3_journal_start(inode, needed);
handle = ext3_journal_start(inode, needed);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
......
......@@ -38,7 +38,6 @@
#include <linux/proc_fs.h>
EXPORT_SYMBOL(journal_start);
EXPORT_SYMBOL(journal_try_start);
EXPORT_SYMBOL(journal_restart);
EXPORT_SYMBOL(journal_extend);
EXPORT_SYMBOL(journal_stop);
......
......@@ -266,113 +266,6 @@ handle_t *journal_start(journal_t *journal, int nblocks)
return handle;
}
/*
* Return zero on success
*/
static int try_start_this_handle(journal_t *journal, handle_t *handle)
{
transaction_t *transaction;
int needed;
int nblocks = handle->h_buffer_credits;
int ret = 0;
jbd_debug(3, "New handle %p maybe going live.\n", handle);
lock_journal(journal);
if (is_journal_aborted(journal) ||
(journal->j_errno != 0 && !(journal->j_flags & JFS_ACK_ERR))) {
ret = -EROFS;
goto fail_unlock;
}
if (journal->j_barrier_count)
goto fail_unlock;
if (!journal->j_running_transaction && get_transaction(journal, 1) == 0)
goto fail_unlock;
transaction = journal->j_running_transaction;
if (transaction->t_state == T_LOCKED)
goto fail_unlock;
needed = transaction->t_outstanding_credits + nblocks;
/* We could run log_start_commit here */
if (needed > journal->j_max_transaction_buffers)
goto fail_unlock;
needed = journal->j_max_transaction_buffers;
if (journal->j_committing_transaction)
needed += journal->j_committing_transaction->
t_outstanding_credits;
if (log_space_left(journal) < needed)
goto fail_unlock;
handle->h_transaction = transaction;
transaction->t_outstanding_credits += nblocks;
transaction->t_updates++;
jbd_debug(4, "Handle %p given %d credits (total %d, free %d)\n",
handle, nblocks, transaction->t_outstanding_credits,
log_space_left(journal));
unlock_journal(journal);
return 0;
fail_unlock:
unlock_journal(journal);
if (ret >= 0)
ret = -1;
return ret;
}
/**
* handle_t *journal_try_start() - Don't block, but try and get a handle
* @journal: Journal to start transaction on.
* @nblocks: number of block buffer we might modify
*
* Try to start a handle, but non-blockingly. If we weren't able
* to, return an ERR_PTR value.
*/
handle_t *journal_try_start(journal_t *journal, int nblocks)
{
handle_t *handle = journal_current_handle();
int err;
if (!journal)
return ERR_PTR(-EROFS);
if (handle) {
jbd_debug(4, "h_ref %d -> %d\n",
handle->h_ref,
handle->h_ref + 1);
J_ASSERT(handle->h_transaction->t_journal == journal);
if (is_handle_aborted(handle))
return ERR_PTR(-EIO);
handle->h_ref++;
return handle;
} else {
jbd_debug(4, "no current transaction\n");
}
if (is_journal_aborted(journal))
return ERR_PTR(-EIO);
handle = new_handle(nblocks);
if (!handle)
return ERR_PTR(-ENOMEM);
current->journal_info = handle;
err = try_start_this_handle(journal, handle);
if (err < 0) {
kfree(handle);
current->journal_info = NULL;
return ERR_PTR(err);
}
return handle;
}
/**
* int journal_extend() - extend buffer credits.
* @handle: handle to 'extend'
......@@ -1726,13 +1619,6 @@ static inline int __journal_try_to_free_buffer(struct buffer_head *bh)
* to be called. We do this if the page is releasable by try_to_free_buffers().
* We also do it if the page has locked or dirty buffers and the caller wants
* us to perform sync or async writeout.
*/
int journal_try_to_free_buffers(journal_t *journal,
struct page *page, int unused_gfp_mask)
{
/*
* journal_try_to_free_buffers(). Try to remove all this page's buffers
* from the journal.
*
* This complicates JBD locking somewhat. We aren't protected by the
* BKL here. We wish to remove the buffer from its committing or
......@@ -1752,6 +1638,9 @@ int journal_try_to_free_buffers(journal_t *journal,
* cannot happen because we never reallocate freed data as metadata
* while the data is part of a transaction. Yes?
*/
int journal_try_to_free_buffers(journal_t *journal,
struct page *page, int unused_gfp_mask)
{
struct buffer_head *head;
struct buffer_head *bh;
int ret = 0;
......
......@@ -210,14 +210,6 @@ static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
return journal_start(journal, nblocks);
}
static inline handle_t *
ext3_journal_try_start(struct inode *inode, int nblocks)
{
if (inode->i_sb->s_flags & MS_RDONLY)
return ERR_PTR(-EROFS);
return journal_try_start(EXT3_JOURNAL(inode), nblocks);
}
/*
* The only special thing we need to do here is to make sure that all
* journal_stop calls result in the superblock being marked dirty, so
......
......@@ -726,7 +726,6 @@ static inline handle_t *journal_current_handle(void)
*/
extern handle_t *journal_start(journal_t *, int nblocks);
extern handle_t *journal_try_start(journal_t *, int nblocks);
extern int journal_restart (handle_t *, int nblocks);
extern int journal_extend (handle_t *, int nblocks);
extern int journal_get_write_access (handle_t *, struct buffer_head *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment