linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Andreas Dilger <adilger@dilger.ca>
Cc: Jan Kara <jack@suse.cz>, Ted Tso <tytso@mit.edu>,
	linux-ext4@vger.kernel.org
Subject: Re: [PATCH 8/8] jbd2: Cleanup journal tail after transaction commit
Date: Thu, 16 Feb 2012 13:59:27 +0100	[thread overview]
Message-ID: <20120216125927.GC18613@quack.suse.cz> (raw)
In-Reply-To: <377B1146-3A57-4959-A0AA-012D5813A514@dilger.ca>

On Wed 15-02-12 14:03:30, Andreas Dilger wrote:
> On 2012-02-15, at 10:34 AM, Jan Kara wrote:
> > Normally, we have to issue a cache flush before we can update journal tail in
> > journal superblock, effectively wiping out old transactions from the journal.
> > So use the fact that during transaction commit we issue cache flush anyway and
> > opportunistically push journal tail as far as we can. Since update of journal
> > superblock is still costly (we have to use WRITE_FUA), we update log tail only
> > if we can free significant amount of space.
> > 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/jbd2/commit.c     |   32 ++++++++++++++++++++++++++++++++
> > fs/jbd2/journal.c    |   13 +++++++++++++
> > include/linux/jbd2.h |    1 +
> > 3 files changed, 46 insertions(+), 0 deletions(-)
> > 
> > diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
> > index f37b783..245201c 100644
> > --- a/fs/jbd2/commit.c
> > +++ b/fs/jbd2/commit.c
> > @@ -331,6 +331,10 @@ void jbd2_journal_commit_transaction(journal_t *journal)
> > 	struct buffer_head *cbh = NULL; /* For transactional checksums */
> > 	__u32 crc32_sum = ~0;
> > 	struct blk_plug plug;
> > +	/* Tail of the journal */
> > +	unsigned long first_block;
> > +	tid_t first_tid;
> > +	int update_tail;
> > 
> > 	/*
> > 	 * First job: lock down the current transaction and wait for
> > @@ -682,10 +686,30 @@ start_journal_io:
> > 		err = 0;
> > 	}
> > 
> > +	/*
> > +	 * Get current oldest transaction in the log before we issue flush
> > +	 * to the filesystem device. After the flush we can be sure that
> > +	 * blocks of all older transactions are checkpointed to persistent
> > +	 * storage and we will be safe to update journal start in the
> > +	 * superblock with the numbers we get here.
> > +	 */
> > +	update_tail =
> > +		jbd2_journal_get_log_tail(journal, &first_tid, &first_block);
> > +
> > 	write_lock(&journal->j_state_lock);
> > +	if (update_tail) {
> > +		long freed = first_block - journal->j_tail;
> > +
> > +		if (first_block < journal->j_tail)
> > +			freed += journal->j_last - journal->j_first;
> > +		/* Update tail only if we free significant amount of space */
> > +		if (freed < journal->j_maxlen / 4)
> > +			update_tail = 0;
> > +	}
> 
> Have you done any performance testing on this?  I expect that it may give
> a nice boost in performance when there are lots of small transactions in
> the journal.  However, it might also increase latency if the journal is
> nearly full and no new transactions can be started until 1/4 of the journal
> is checkpointed.
  Well, I didn't do serious performance testing because I failed to find a
workload where I would think it could make a difference. For example for
workload creating and deleting directories and 0-length files, I saw about
one jbd2_cleanup_journal_tail() invocation per 200 transaction commits. So
the possible gain would be very well in the noise.

> This should probably be conditional on a decent amount of free blocks left
> in the journal, for example:
> 
> 		if (j_free >= j_maxlen / 8 && freed < journal->j_maxlen / 4)
> 			update_tail = 0;
> 
> or
> 		if (freed >= j_free)
> 			update_tail = 0;
  Yeah. Currently, I'm doubtful we should apply this patch at all. But if
we do, tweaking the condition is certainly possible. I mostly wanted to
gather people's thoughts regarding this particular patch in the first
round.

  Thanks for your comments.
								Honza

  reply	other threads:[~2012-02-16 12:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15 18:34 [PATCH 0/8 v3] Checkpointing fixes and cleanups Jan Kara
2012-02-15 18:34 ` [PATCH 1/8] jbd2: Split updating of journal superblock and marking journal empty Jan Kara
2012-02-15 18:34 ` [PATCH 2/8] jbd2: Protect all log tail updates with j_checkpoint_mutex Jan Kara
2012-02-15 18:34 ` [PATCH 3/8] jbd2: Issue cache flush after checkpointing even with internal journal Jan Kara
2012-03-14  2:17   ` Ted Ts'o
2012-03-15  8:59     ` Jan Kara
2012-03-19  3:45       ` Ted Ts'o
2012-02-15 18:34 ` [PATCH 4/8] jbd2: Fix BH_JWrite setting in checkpointing code Jan Kara
2012-02-15 18:34 ` [PATCH 5/8] jbd2: __jbd2_journal_temp_unlink_buffer() is static Jan Kara
2012-02-15 18:34 ` [PATCH 6/8] jbd2: Remove always true condition in __journal_try_to_free_buffer() Jan Kara
2012-02-15 18:34 ` [PATCH 7/8] jbd2: Remove bh_state lock from checkpointing code Jan Kara
2012-02-15 18:34 ` [PATCH 8/8] jbd2: Cleanup journal tail after transaction commit Jan Kara
2012-02-15 22:03   ` Andreas Dilger
2012-02-16 12:59     ` Jan Kara [this message]
2012-02-29 11:03 ` [PATCH 0/8 v3] Checkpointing fixes and cleanups Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120216125927.GC18613@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).