Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261618AbVAXU1A (ORCPT ); Mon, 24 Jan 2005 15:27:00 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261620AbVAXUZ6 (ORCPT ); Mon, 24 Jan 2005 15:25:58 -0500 Received: from [83.102.214.158] ([83.102.214.158]:2536 "EHLO gw.home.net") by vger.kernel.org with ESMTP id S261625AbVAXUX3 (ORCPT ); Mon, 24 Jan 2005 15:23:29 -0500 X-Comment-To: "Stephen C. Tweedie" To: "Stephen C. Tweedie" Cc: Alex Tomas , linux-kernel , , Andrew Morton Subject: Re: [Ext2-devel] [PATCH] JBD: log space management optimization References: <1106593003.2103.147.camel@sisko.sctweedie.blueyonder.co.uk> From: Alex Tomas Organization: HOME Date: Mon, 24 Jan 2005 23:22:08 +0300 Message-ID: User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2222 Lines: 77 >>>>> Stephen C Tweedie (SCT) writes: SCT> If you returned them to the handle directly, it would be slightly more SCT> efficient. good point. thanks. here is the fixed patch. during truncate ext3 calls journal_forget() for freed blocks, but before these blocks go to the transaction and jbd reserves space in log for them (->t_outstanding_credits). also, journal_forget() removes these blocks from the transaction, but doesn't correct log space reservation. for example, removal of 500MB file reserves 136 blocks, but only 10 blocks go to the log. a commit is expensive and correct reservation allows us to avoid needless commits. here is the patch. tested on UP. Signed-off-by: Alex Tomas Index: linux-2.6.7/fs/jbd/transaction.c =================================================================== --- linux-2.6.7.orig/fs/jbd/transaction.c 2004-08-26 17:12:40.000000000 +0400 +++ linux-2.6.7/fs/jbd/transaction.c 2005-01-24 22:51:34.000000000 +0300 @@ -1204,6 +1204,7 @@ transaction_t *transaction = handle->h_transaction; journal_t *journal = transaction->t_journal; struct journal_head *jh; + int drop_reserve = 0; BUFFER_TRACE(bh, "entry"); @@ -1227,6 +1228,7 @@ J_ASSERT_JH(jh, !jh->b_committed_data); __journal_unfile_buffer(jh); + drop_reserve = 1; /* * We are no longer going to journal this buffer. @@ -1249,7 +1251,7 @@ spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); __bforget(bh); - return; + goto drop; } } } else if (jh->b_transaction) { @@ -1264,6 +1266,7 @@ if (jh->b_next_transaction) { J_ASSERT(jh->b_next_transaction == transaction); jh->b_next_transaction = NULL; + drop_reserve = 1; } } @@ -1271,6 +1274,13 @@ spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); __brelse(bh); + +drop: + if (drop_reserve) { + /* no need to reserve log space for this block -bzzz */ + handle->h_buffer_credits++; + } + return; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/