Skip to content

Commit 90e86a6

Browse files
jankaraMark Fasheh
authored andcommitted
ocfs2: Support nested transactions
OCFS2 can easily support nested transactions. We just have to take care and not spoil statistics acquire semaphore unnecessarily. Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Mark Fasheh <[email protected]>
1 parent 12c7752 commit 90e86a6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/ocfs2/journal.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,9 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
256256
BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
257257
BUG_ON(max_buffs <= 0);
258258

259-
/* JBD might support this, but our journalling code doesn't yet. */
260-
if (journal_current_handle()) {
261-
mlog(ML_ERROR, "Recursive transaction attempted!\n");
262-
BUG();
263-
}
259+
/* Nested transaction? Just return the handle... */
260+
if (journal_current_handle())
261+
return jbd2_journal_start(journal, max_buffs);
264262

265263
down_read(&osb->journal->j_trans_barrier);
266264

@@ -285,16 +283,18 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
285283
int ocfs2_commit_trans(struct ocfs2_super *osb,
286284
handle_t *handle)
287285
{
288-
int ret;
286+
int ret, nested;
289287
struct ocfs2_journal *journal = osb->journal;
290288

291289
BUG_ON(!handle);
292290

291+
nested = handle->h_ref > 1;
293292
ret = jbd2_journal_stop(handle);
294293
if (ret < 0)
295294
mlog_errno(ret);
296295

297-
up_read(&journal->j_trans_barrier);
296+
if (!nested)
297+
up_read(&journal->j_trans_barrier);
298298

299299
return ret;
300300
}

0 commit comments

Comments
 (0)