Commit 90e86a63eadf1a3b2f19b68d82150dc63fe01443

Authored by Jan Kara
Committed by Mark Fasheh
1 parent 12c77527e4

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 <jack@suse.cz>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>

Showing 1 changed file with 7 additions and 7 deletions Side-by-side Diff

... ... @@ -256,11 +256,9 @@
256 256 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
257 257 BUG_ON(max_buffs <= 0);
258 258  
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);
264 262  
265 263 down_read(&osb->journal->j_trans_barrier);
266 264  
267 265  
268 266  
... ... @@ -285,16 +283,18 @@
285 283 int ocfs2_commit_trans(struct ocfs2_super *osb,
286 284 handle_t *handle)
287 285 {
288   - int ret;
  286 + int ret, nested;
289 287 struct ocfs2_journal *journal = osb->journal;
290 288  
291 289 BUG_ON(!handle);
292 290  
  291 + nested = handle->h_ref > 1;
293 292 ret = jbd2_journal_stop(handle);
294 293 if (ret < 0)
295 294 mlog_errno(ret);
296 295  
297   - up_read(&journal->j_trans_barrier);
  296 + if (!nested)
  297 + up_read(&journal->j_trans_barrier);
298 298  
299 299 return ret;
300 300 }