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 kswad for too long. It was never clearly necessary, and as ->writepage is now used for regular synchronous writeback, blocking in ->writepage is in some ways desirable. So the patch throws it all away and just calls the blocking journal_start() from ext3_writepage(). fs/ext3/inode.c | 5 -- fs/jbd/journal.c | 1 fs/jbd/transaction.c | 117 +---------------------------------------------- include/linux/ext3_jbd.h | 8 --- include/linux/jbd.h | 1 do_mounts.c | 0 6 files changed, 4 insertions(+), 128 deletions(-) diff -puN fs/jbd/transaction.c~remove-journal_try_start fs/jbd/transaction.c --- 25/fs/jbd/transaction.c~remove-journal_try_start Thu Feb 6 14:34:42 2003 +++ 25-akpm/fs/jbd/transaction.c Thu Feb 6 14:34:42 2003 @@ -266,113 +266,6 @@ handle_t *journal_start(journal_t *journ 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 @@ out: * 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_ * 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; diff -puN include/linux/jbd.h~remove-journal_try_start include/linux/jbd.h --- 25/include/linux/jbd.h~remove-journal_try_start Thu Feb 6 14:34:42 2003 +++ 25-akpm/include/linux/jbd.h Thu Feb 6 14:34:42 2003 @@ -726,7 +726,6 @@ static inline handle_t *journal_current_ */ 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 *); diff -puN include/linux/ext3_jbd.h~remove-journal_try_start include/linux/ext3_jbd.h --- 25/include/linux/ext3_jbd.h~remove-journal_try_start Thu Feb 6 14:34:42 2003 +++ 25-akpm/include/linux/ext3_jbd.h Thu Feb 6 14:34:42 2003 @@ -210,14 +210,6 @@ static inline handle_t *ext3_journal_sta 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 diff -puN fs/ext3/inode.c~remove-journal_try_start fs/ext3/inode.c --- 25/fs/ext3/inode.c~remove-journal_try_start Thu Feb 6 14:34:42 2003 +++ 25-akpm/fs/ext3/inode.c Thu Feb 6 14:34:42 2003 @@ -1317,10 +1317,7 @@ static int ext3_writepage(struct page *p 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); diff -puN fs/jbd/journal.c~remove-journal_try_start fs/jbd/journal.c --- 25/fs/jbd/journal.c~remove-journal_try_start Thu Feb 6 14:34:42 2003 +++ 25-akpm/fs/jbd/journal.c Thu Feb 6 14:34:42 2003 @@ -38,7 +38,6 @@ #include EXPORT_SYMBOL(journal_start); -EXPORT_SYMBOL(journal_try_start); EXPORT_SYMBOL(journal_restart); EXPORT_SYMBOL(journal_extend); EXPORT_SYMBOL(journal_stop); diff -puN init/do_mounts.c~remove-journal_try_start init/do_mounts.c _