%patch
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.1199  -> 1.1200
#        fs/reiserfs/inode.c    1.49    -> 1.50
#       fs/reiserfs/journal.c   1.31    -> 1.32
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/12/03      [email protected]   1.1200
# journal.c, inode.c:
#   reiserfs-free-blocks
# --------------------------------------------
#
diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
--- a/fs/reiserfs/inode.c       Wed Dec  3 18:13:01 2003
+++ b/fs/reiserfs/inode.c       Wed Dec  3 18:13:01 2003
@@ -628,7 +628,11 @@
           /* restart the transaction to give the journal a chance to free
           ** some blocks.  releases the path, so we have to go back to
           ** research if we succeed on the second try
+           **
+           ** the journal won't free the blocks if we don't force a commit
+           ** and wait for it
           */
+           SB_JOURNAL(inode->i_sb)->j_next_async_flush = 1;
           restart_transaction(&th, inode, &path) ;
           repeat = _allocate_block(&th, block, inode, &allocated_block_nr, NULL, create);

diff -Nru a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
--- a/fs/reiserfs/journal.c     Wed Dec  3 18:13:01 2003
+++ b/fs/reiserfs/journal.c     Wed Dec  3 18:13:01 2003
@@ -2996,7 +2996,6 @@
  int jindex ;
  int orig_jindex ;
  int flush = flags & FLUSH_ALL ;
-  int commit_now = flags & COMMIT_NOW ;
  int wait_on_commit = flags & WAIT ;
  struct reiserfs_super_block *rs ;

@@ -3010,8 +3009,8 @@
    flush = 1 ;
  }
  if (SB_JOURNAL(p_s_sb)->j_next_async_flush) {
-    flags |= COMMIT_NOW ;
-    commit_now = 1 ;
+    flags |= COMMIT_NOW | WAIT;
+    wait_on_commit = 1;
  }

  /* check_journal_end locks the journal, and unlocks if it does not return 1
@@ -3025,9 +3024,6 @@
  if (SB_JOURNAL(p_s_sb)->j_next_full_flush) {
    flush = 1 ;
  }
-  if (SB_JOURNAL(p_s_sb)->j_next_async_flush) {
-    commit_now = 1 ;
-  }
  /*
  ** j must wait means we have to flush the log blocks, and the real blocks for
  ** this transaction
@@ -3191,15 +3187,12 @@

  /* honor the flush and async wishes from the caller */
  if (flush) {
-
    flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex, 1) ;
    flush_journal_list(p_s_sb,  SB_JOURNAL_LIST(p_s_sb) + orig_jindex , 1) ;
-  } else if (commit_now) {
-    if (wait_on_commit) {
-      flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex, 1) ;
-    } else {
-      commit_flush_async(p_s_sb, orig_jindex) ;
-    }
+  } else if (wait_on_commit) {
+    flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex, 1) ;
+  } else {
+    commit_flush_async(p_s_sb, orig_jindex) ;
  }

  /* reset journal values for the next transaction */
@@ -3263,6 +3256,3 @@
  wake_up(&(SB_JOURNAL(p_s_sb)->j_join_wait)) ;
  return 0 ;
}
-
-
-