|
@@ -529,20 +529,17 @@ int jbd2_log_start_commit(journal_t *journal, tid_t tid)
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Force and wait upon a commit if the calling process is not within
|
|
|
|
- * transaction. This is used for forcing out undo-protected data which contains
|
|
|
|
- * bitmaps, when the fs is running out of space.
|
|
|
|
- *
|
|
|
|
- * We can only force the running transaction if we don't have an active handle;
|
|
|
|
- * otherwise, we will deadlock.
|
|
|
|
- *
|
|
|
|
- * Returns true if a transaction was started.
|
|
|
|
|
|
+ * Force and wait any uncommitted transactions. We can only force the running
|
|
|
|
+ * transaction if we don't have an active handle, otherwise, we will deadlock.
|
|
|
|
+ * Returns: <0 in case of error,
|
|
|
|
+ * 0 if nothing to commit,
|
|
|
|
+ * 1 if transaction was successfully committed.
|
|
*/
|
|
*/
|
|
-int jbd2_journal_force_commit_nested(journal_t *journal)
|
|
|
|
|
|
+static int __jbd2_journal_force_commit(journal_t *journal)
|
|
{
|
|
{
|
|
transaction_t *transaction = NULL;
|
|
transaction_t *transaction = NULL;
|
|
tid_t tid;
|
|
tid_t tid;
|
|
- int need_to_start = 0;
|
|
|
|
|
|
+ int need_to_start = 0, ret = 0;
|
|
|
|
|
|
read_lock(&journal->j_state_lock);
|
|
read_lock(&journal->j_state_lock);
|
|
if (journal->j_running_transaction && !current->journal_info) {
|
|
if (journal->j_running_transaction && !current->journal_info) {
|
|
@@ -553,16 +550,53 @@ int jbd2_journal_force_commit_nested(journal_t *journal)
|
|
transaction = journal->j_committing_transaction;
|
|
transaction = journal->j_committing_transaction;
|
|
|
|
|
|
if (!transaction) {
|
|
if (!transaction) {
|
|
|
|
+ /* Nothing to commit */
|
|
read_unlock(&journal->j_state_lock);
|
|
read_unlock(&journal->j_state_lock);
|
|
- return 0; /* Nothing to retry */
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
tid = transaction->t_tid;
|
|
tid = transaction->t_tid;
|
|
read_unlock(&journal->j_state_lock);
|
|
read_unlock(&journal->j_state_lock);
|
|
if (need_to_start)
|
|
if (need_to_start)
|
|
jbd2_log_start_commit(journal, tid);
|
|
jbd2_log_start_commit(journal, tid);
|
|
- jbd2_log_wait_commit(journal, tid);
|
|
|
|
- return 1;
|
|
|
|
|
|
+ ret = jbd2_log_wait_commit(journal, tid);
|
|
|
|
+ if (!ret)
|
|
|
|
+ ret = 1;
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Force and wait upon a commit if the calling process is not within
|
|
|
|
+ * transaction. This is used for forcing out undo-protected data which contains
|
|
|
|
+ * bitmaps, when the fs is running out of space.
|
|
|
|
+ *
|
|
|
|
+ * @journal: journal to force
|
|
|
|
+ * Returns true if progress was made.
|
|
|
|
+ */
|
|
|
|
+int jbd2_journal_force_commit_nested(journal_t *journal)
|
|
|
|
+{
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ ret = __jbd2_journal_force_commit(journal);
|
|
|
|
+ return ret > 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * int journal_force_commit() - force any uncommitted transactions
|
|
|
|
+ * @journal: journal to force
|
|
|
|
+ *
|
|
|
|
+ * Caller want unconditional commit. We can only force the running transaction
|
|
|
|
+ * if we don't have an active handle, otherwise, we will deadlock.
|
|
|
|
+ */
|
|
|
|
+int jbd2_journal_force_commit(journal_t *journal)
|
|
|
|
+{
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ J_ASSERT(!current->journal_info);
|
|
|
|
+ ret = __jbd2_journal_force_commit(journal);
|
|
|
|
+ if (ret > 0)
|
|
|
|
+ ret = 0;
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|