From: Dmitry Monakhov <dmonakhov@openvz.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH 1/2] jbd: Provide function to check whether transaction will issue data barrier
Date: Tue, 27 Apr 2010 07:42:49 +0400 [thread overview]
Message-ID: <87eii1d0hy.fsf@openvz.org> (raw)
In-Reply-To: <1272312659-16468-2-git-send-email-jack@suse.cz> (Jan Kara's message of "Mon, 26 Apr 2010 22:10:58 +0200")
Jan Kara <jack@suse.cz> writes:
> Provide a function which returns whether a transaction with given tid
> will send a barrier to the filesystem device. The function will be used
> by ext3 to detect whether fsync needs to send a separate barrier or not.
Agree. Except the fact that in case of j_dev != j_fs_dev jbd is still
broken. I'm plan to post back-port from jbd2 which makes
journal_trans_will_send_data_barrier() more complex. It have to analyze
commit_transaction->t_flushed_data_blocks.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/jbd/commit.c | 8 +++++++-
> fs/jbd/journal.c | 33 +++++++++++++++++++++++++++++++++
> include/linux/jbd.h | 3 ++-
> 3 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
> index ecb44c9..28a9dda 100644
> --- a/fs/jbd/commit.c
> +++ b/fs/jbd/commit.c
> @@ -786,6 +786,12 @@ wait_for_iobuf:
>
> jbd_debug(3, "JBD: commit phase 6\n");
>
> + /* All metadata is written, now write commit record and do cleanup */
> + spin_lock(&journal->j_state_lock);
> + J_ASSERT(commit_transaction->t_state == T_COMMIT);
> + commit_transaction->t_state = T_COMMIT_RECORD;
> + spin_unlock(&journal->j_state_lock);
> +
> if (journal_write_commit_record(journal, commit_transaction))
> err = -EIO;
>
> @@ -923,7 +929,7 @@ restart_loop:
>
> jbd_debug(3, "JBD: commit phase 8\n");
>
> - J_ASSERT(commit_transaction->t_state == T_COMMIT);
> + J_ASSERT(commit_transaction->t_state == T_COMMIT_RECORD);
>
> commit_transaction->t_state = T_FINISHED;
> J_ASSERT(commit_transaction == journal->j_committing_transaction);
> diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
> index bd224ee..99c7194 100644
> --- a/fs/jbd/journal.c
> +++ b/fs/jbd/journal.c
> @@ -565,6 +565,38 @@ int log_wait_commit(journal_t *journal, tid_t tid)
> }
>
> /*
> + * Return 1 if a given transaction has not yet sent barrier request
> + * connected with a transaction commit. If 0 is returned, transaction
> + * may or may not have sent the barrier. Used to avoid sending barrier
> + * twice in common cases.
> + */
> +int journal_trans_will_send_data_barrier(journal_t *journal, tid_t tid)
> +{
> + int ret = 0;
> + transaction_t *commit_trans;
> +
> + if (!(journal->j_flags & JFS_BARRIER))
> + return 0;
> + spin_lock(&journal->j_state_lock);
> + /* Transaction already committed? */
> + if (tid_geq(journal->j_commit_sequence, tid))
> + goto out;
> + /*
> + * Transaction is being committed and we already proceeded to
> + * writing commit record?
> + */
> + commit_trans = journal->j_committing_transaction;
> + if (commit_trans && commit_trans->t_tid == tid &&
> + commit_trans->t_state >= T_COMMIT_RECORD)
> + goto out;
> + ret = 1;
> +out:
> + spin_unlock(&journal->j_state_lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(journal_commit_will_send_barrier);
> +
> +/*
> * Log buffer allocation routines:
> */
>
> @@ -1157,6 +1189,7 @@ int journal_destroy(journal_t *journal)
> {
> int err = 0;
>
> +
> /* Wait for the commit thread to wake up and die. */
> journal_kill_thread(journal);
>
> diff --git a/include/linux/jbd.h b/include/linux/jbd.h
> index 516a2a2..e069650 100644
> --- a/include/linux/jbd.h
> +++ b/include/linux/jbd.h
> @@ -427,9 +427,9 @@ struct transaction_s
> enum {
> T_RUNNING,
> T_LOCKED,
> - T_RUNDOWN,
> T_FLUSH,
> T_COMMIT,
> + T_COMMIT_RECORD,
> T_FINISHED
> } t_state;
>
> @@ -991,6 +991,7 @@ int journal_start_commit(journal_t *journal, tid_t *tid);
> int journal_force_commit_nested(journal_t *journal);
> int log_wait_commit(journal_t *journal, tid_t tid);
> int log_do_checkpoint(journal_t *journal);
> +int journal_trans_will_send_data_barrier(journal_t *journal, tid_t tid);
>
> void __log_wait_for_space(journal_t *journal);
> extern void __journal_drop_transaction(journal_t *, transaction_t *);
next prev parent reply other threads:[~2010-04-27 3:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-26 20:10 [PATCH 0/2] Fix waiting on transaction in ext3_sync_file Jan Kara
2010-04-26 20:10 ` [PATCH 1/2] jbd: Provide function to check whether transaction will issue data barrier Jan Kara
2010-04-27 3:42 ` Dmitry Monakhov [this message]
2010-04-27 20:48 ` Jan Kara
2010-04-26 20:10 ` [PATCH 2/2] ext3: Fix waiting on transaction during fsync 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=87eii1d0hy.fsf@openvz.org \
--to=dmonakhov@openvz.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.